ssb-sgis 1.0.2__py3-none-any.whl → 1.0.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. sgis/__init__.py +20 -9
  2. sgis/debug_config.py +24 -0
  3. sgis/exceptions.py +2 -2
  4. sgis/geopandas_tools/bounds.py +33 -36
  5. sgis/geopandas_tools/buffer_dissolve_explode.py +136 -35
  6. sgis/geopandas_tools/centerlines.py +4 -91
  7. sgis/geopandas_tools/cleaning.py +1576 -583
  8. sgis/geopandas_tools/conversion.py +38 -19
  9. sgis/geopandas_tools/duplicates.py +29 -8
  10. sgis/geopandas_tools/general.py +263 -100
  11. sgis/geopandas_tools/geometry_types.py +4 -4
  12. sgis/geopandas_tools/neighbors.py +19 -15
  13. sgis/geopandas_tools/overlay.py +2 -2
  14. sgis/geopandas_tools/point_operations.py +5 -5
  15. sgis/geopandas_tools/polygon_operations.py +510 -105
  16. sgis/geopandas_tools/polygons_as_rings.py +40 -8
  17. sgis/geopandas_tools/sfilter.py +29 -12
  18. sgis/helpers.py +3 -3
  19. sgis/io/dapla_functions.py +238 -19
  20. sgis/io/read_parquet.py +1 -1
  21. sgis/maps/examine.py +27 -12
  22. sgis/maps/explore.py +450 -65
  23. sgis/maps/legend.py +177 -76
  24. sgis/maps/map.py +206 -103
  25. sgis/maps/maps.py +178 -105
  26. sgis/maps/thematicmap.py +243 -83
  27. sgis/networkanalysis/_service_area.py +6 -1
  28. sgis/networkanalysis/closing_network_holes.py +2 -2
  29. sgis/networkanalysis/cutting_lines.py +15 -8
  30. sgis/networkanalysis/directednetwork.py +1 -1
  31. sgis/networkanalysis/finding_isolated_networks.py +15 -8
  32. sgis/networkanalysis/networkanalysis.py +17 -19
  33. sgis/networkanalysis/networkanalysisrules.py +1 -1
  34. sgis/networkanalysis/traveling_salesman.py +1 -1
  35. sgis/parallel/parallel.py +64 -27
  36. sgis/raster/__init__.py +0 -6
  37. sgis/raster/base.py +208 -0
  38. sgis/raster/cube.py +54 -8
  39. sgis/raster/image_collection.py +3257 -0
  40. sgis/raster/indices.py +17 -5
  41. sgis/raster/raster.py +138 -243
  42. sgis/raster/sentinel_config.py +120 -0
  43. sgis/raster/zonal.py +0 -1
  44. {ssb_sgis-1.0.2.dist-info → ssb_sgis-1.0.4.dist-info}/METADATA +6 -7
  45. ssb_sgis-1.0.4.dist-info/RECORD +62 -0
  46. sgis/raster/methods_as_functions.py +0 -0
  47. sgis/raster/torchgeo.py +0 -171
  48. ssb_sgis-1.0.2.dist-info/RECORD +0 -61
  49. {ssb_sgis-1.0.2.dist-info → ssb_sgis-1.0.4.dist-info}/LICENSE +0 -0
  50. {ssb_sgis-1.0.2.dist-info → ssb_sgis-1.0.4.dist-info}/WHEEL +0 -0
@@ -0,0 +1,120 @@
1
+ import re
2
+
3
+ SENTINEL2_FILENAME_REGEX = r"""
4
+ ^(?P<tile>T\d{2}[A-Z]{3})
5
+ _(?P<date>\d{8})T\d{6}
6
+ _(?P<band>B[018][\dA])
7
+ (?:_(?P<resolution>\d+)m)?
8
+ .*
9
+ \..*$
10
+ """
11
+
12
+
13
+ SENTINEL2_CLOUD_FILENAME_REGEX = r"""
14
+ ^(?P<tile>T\d{2}[A-Z]{3})
15
+ _(?P<date>\d{8})T\d{6}
16
+ _(?P<band>SCL)
17
+ (?:_(?P<resolution>\d+)m)?
18
+ .*
19
+ \..*$
20
+ """
21
+
22
+ SENTINEL2_IMAGE_REGEX = r"""
23
+ ^(?P<mission_id>S2[AB])
24
+ _MSI(?P<level>[A-Z]\d{1}[A-Z])
25
+ _(?P<date>\d{8})T\d{6}
26
+ _(?P<baseline>N\d{4})
27
+ _(?P<orbit>R\d{3})
28
+ _(?P<tile>T\d{2}[A-Z]{3})
29
+ _\d{8}T\d{6}
30
+ .*
31
+ .*$
32
+ """
33
+
34
+ SENTINEL2_MOSAIC_FILENAME_REGEX = r"""
35
+ ^SENTINEL2X_
36
+ (?P<date>\d{8})
37
+ .*?
38
+ (?P<tile>T\d{2}[A-Z]{3})
39
+ .*?
40
+ _(?P<band>B\d{1,2}A?)_
41
+ .*?
42
+ (?:_(?P<resolution>\d+m))?
43
+ .*?\.tif$
44
+ """
45
+
46
+ SENTINEL2_MOSAIC_IMAGE_REGEX = r"""
47
+ ^SENTINEL2X_
48
+ (?P<date>\d{8})
49
+ -\d{6}
50
+ -\d{3}
51
+ _(?P<level>[A-Z]\d{1}[A-Z])
52
+ .*(?P<tile>T\d{2}[A-Z]{3})
53
+ .*.*$
54
+ """
55
+
56
+
57
+ # multiple regex searches because there are different xml files with same info, but different naming
58
+ CLOUD_COVERAGE_REGEXES: tuple[str] = (
59
+ r"<Cloud_Coverage_Assessment>([\d.]+)</Cloud_Coverage_Assessment>",
60
+ r"<CLOUDY_PIXEL_OVER_LAND_PERCENTAGE>([\d.]+)</CLOUDY_PIXEL_OVER_LAND_PERCENTAGE>",
61
+ )
62
+
63
+ CRS_REGEXES: tuple[str] = (r"<HORIZONTAL_CS_CODE>EPSG:(\d+)</HORIZONTAL_CS_CODE>",)
64
+
65
+ BOUNDS_REGEXES: tuple[dict[str, str]] = (
66
+ {"minx": r"<ULX>(\d+)</ULX>", "maxy": r"<ULY>(\d+)</ULY>"},
67
+ )
68
+ BOUNDS_REGEXES: tuple[re.Pattern] = (
69
+ re.compile(r"<ULX>(?P<minx>\d+)</ULX>"),
70
+ re.compile(r"<ULY>(?P<maxy>\d+)</ULY>"),
71
+ # )
72
+ # SHAPE_PATTERNS: tuple[re.Pattern] = (
73
+ re.compile(
74
+ r'<Size resolution="(?P<resolution>\d+)">\s*<NROWS>(?P<nrows>\d+)</NROWS>\s*<NCOLS>(?P<ncols>\d+)</NCOLS>\s*</Size>'
75
+ ),
76
+ re.compile(
77
+ r"<Cloud_Coverage_Assessment>(?P<cloud_coverage_percentage>[\d.]+)</Cloud_Coverage_Assessment>"
78
+ ),
79
+ re.compile(
80
+ r"<CLOUDY_PIXEL_OVER_LAND_PERCENTAGE>(?P<cloud_coverage_percentage>[\d.]+)</CLOUDY_PIXEL_OVER_LAND_PERCENTAGE>"
81
+ ),
82
+ )
83
+
84
+ SENTINEL2_L2A_BANDS = {
85
+ "B01": 60,
86
+ "B02": 10,
87
+ "B03": 10,
88
+ "B04": 10,
89
+ "B05": 20,
90
+ "B06": 20,
91
+ "B07": 20,
92
+ "B08": 10,
93
+ "B8A": 20,
94
+ "B09": 60,
95
+ "B11": 20,
96
+ "B12": 20,
97
+ }
98
+ SENTINEL2_L1C_BANDS = SENTINEL2_L2A_BANDS | {"B10": 60}
99
+ SENTINEL2_CLOUD_BANDS = {
100
+ "SCL": 20, # SCL: scene classification
101
+ }
102
+
103
+ SENTINEL2_SCL_CLASSES = {
104
+ 0: "No Data (Missing data)", # 000000
105
+ 1: "Saturated or defective pixel", # ff0000
106
+ 2: "Topographic casted shadows", # 2f2f2f
107
+ 3: "Cloud shadows", # 643200
108
+ 4: "Vegetation", # 00a000
109
+ 5: "Not-vegetated", # ffe65a
110
+ 6: "Water", # 0000ff
111
+ 7: "Unclassified", # 808080
112
+ 8: "Cloud medium probability", # c0c0c0
113
+ 9: "Cloud high probability", # ffffff
114
+ 10: "Thin cirrus", # 64c8ff
115
+ 11: "Snow or ice", # ff96ff
116
+ }
117
+
118
+ SENTINEL2_BANDS = SENTINEL2_L1C_BANDS | SENTINEL2_CLOUD_BANDS
119
+ SENTINEL2_RBG_BANDS = ["B02", "B03", "B04"]
120
+ SENTINEL2_NDVI_BANDS = ["B04", "B08"]
sgis/raster/zonal.py CHANGED
@@ -87,7 +87,6 @@ def _clip_and_aggregate(
87
87
  if not len(cube):
88
88
  return _no_overlap_df(func_names, i, date)
89
89
  clipped = cube.clipmerge(polygon)
90
- print(list(clipped))
91
90
  if not len(clipped) or [arr is None for arr in clipped.arrays]:
92
91
  return _no_overlap_df(func_names, i, date)
93
92
  assert len(clipped) == 1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ssb-sgis
3
- Version: 1.0.2
3
+ Version: 1.0.4
4
4
  Summary: GIS functions used at Statistics Norway.
5
5
  Home-page: https://github.com/statisticsnorway/ssb-sgis
6
6
  License: MIT
@@ -21,12 +21,10 @@ Provides-Extra: torch
21
21
  Provides-Extra: xarray
22
22
  Requires-Dist: affine (>=2.4.0)
23
23
  Requires-Dist: branca (>=0.6.0)
24
- Requires-Dist: dapla-toolbelt (>=2.0.12) ; extra == "all" or extra == "bucket"
25
- Requires-Dist: dask (>=2024.1.1)
26
- Requires-Dist: dask-geopandas (>=0.3.0)
24
+ Requires-Dist: dapla-toolbelt (>=3.0.1) ; extra == "all" or extra == "bucket"
25
+ Requires-Dist: dask (>=2024.1.1) ; extra == "all" or extra == "test"
27
26
  Requires-Dist: folium (>=0.14.0)
28
27
  Requires-Dist: gcsfs (>=2024.3.1) ; extra == "all" or extra == "bucket"
29
- Requires-Dist: geocoder (>=1.38.1)
30
28
  Requires-Dist: geopandas (>=0.14.0)
31
29
  Requires-Dist: igraph (>=0.11.2)
32
30
  Requires-Dist: ipython (>=8.13.2)
@@ -36,7 +34,8 @@ Requires-Dist: joblib (>=1.4.0)
36
34
  Requires-Dist: mapclassify (>=2.5.0)
37
35
  Requires-Dist: matplotlib (>=3.7.0)
38
36
  Requires-Dist: networkx (>=3.0)
39
- Requires-Dist: numpy (>=1.24.2)
37
+ Requires-Dist: numba (>=0.60.0)
38
+ Requires-Dist: numpy (>=1.26.4)
40
39
  Requires-Dist: pandas (>=2.2.1)
41
40
  Requires-Dist: pyarrow (>=11.0.0)
42
41
  Requires-Dist: pyproj (>=3.6.1)
@@ -46,7 +45,7 @@ Requires-Dist: rioxarray (>=0.15.5) ; extra == "all" or extra == "xarray" or ext
46
45
  Requires-Dist: rtree (>=1.0.1)
47
46
  Requires-Dist: scikit-learn (>=1.2.1)
48
47
  Requires-Dist: shapely (>=2.0.1)
49
- Requires-Dist: torch (==2.2.2) ; extra == "all" or extra == "torch" or extra == "test"
48
+ Requires-Dist: torch (>=2.4.0) ; extra == "all" or extra == "torch" or extra == "test"
50
49
  Requires-Dist: torchgeo (>=0.5.2) ; extra == "all" or extra == "torch" or extra == "test"
51
50
  Requires-Dist: typing-extensions (>=4.11.0)
52
51
  Requires-Dist: xarray (>=2024.3.0) ; extra == "all" or extra == "xarray" or extra == "test"
@@ -0,0 +1,62 @@
1
+ sgis/__init__.py,sha256=wuANmvvdEus5xumwqVXC1xUUDajThjYuS5jBwfPYCeI,7266
2
+ sgis/debug_config.py,sha256=hIJEz3cIDjoxrtRMuVcNQSXZHCRTbh63Tri4IR7iVFM,545
3
+ sgis/exceptions.py,sha256=WNaEBPNNx0rmz-YDzlFX4vIE7ocJQruUTqS2RNAu2zU,660
4
+ sgis/geopandas_tools/__init__.py,sha256=bo8lFMcltOz7TtWAi52_ekR2gd3mjfBfKeMDV5zuqFY,28
5
+ sgis/geopandas_tools/bounds.py,sha256=iIIqacQafn4XrWDaJtaffLrW72z3ce_-YYwdTtWmA8E,23673
6
+ sgis/geopandas_tools/buffer_dissolve_explode.py,sha256=_0XgfC4DSUEKF4sbGr2KpMSngCrPrZt_d7siy0vILLU,21083
7
+ sgis/geopandas_tools/centerlines.py,sha256=Q65Sx01SeAlulBEd9oaZkB2maBBNdLcJwAbTILg4SPU,11848
8
+ sgis/geopandas_tools/cleaning.py,sha256=I3tpn5uzsLjRYi-TybUe3QuNns0CseuxkfBSmSMer0I,60208
9
+ sgis/geopandas_tools/conversion.py,sha256=TkfSu-DRHicH8LSR7ygMN84ggxP_zzmFk54iLNv1ftg,24660
10
+ sgis/geopandas_tools/duplicates.py,sha256=LG8-BG8LdA2zjWauuloslIZHvMGND6Fja0MtXIPZ1wo,14301
11
+ sgis/geopandas_tools/general.py,sha256=5ZD7CXGIvJmWDN-V-RlG0K_mWiT6iVNvP_UL8cufk2A,31651
12
+ sgis/geopandas_tools/geocoding.py,sha256=n47aFQMm4yX1MsPnTM4dFjwegCA1ZmGUDj1uyu7OJV4,691
13
+ sgis/geopandas_tools/geometry_types.py,sha256=hSlN8n4pJZPkEfOdKL1DRux757kl81DciIH7ZXiHEdE,7587
14
+ sgis/geopandas_tools/neighbors.py,sha256=vduQlHeoZjHyD5pxDbjfonQ3-LAHGfPETxV7-L6Sg4M,16634
15
+ sgis/geopandas_tools/overlay.py,sha256=IADAh-U9EUgDLSsyYcblL3Qbjxi89xRHtP20KdhlYaA,25543
16
+ sgis/geopandas_tools/point_operations.py,sha256=JM4hvfIVxZaZdGNlGzcCurrKzkgC_b9hzbFYN42f9WY,6972
17
+ sgis/geopandas_tools/polygon_operations.py,sha256=FJ-dXCxLHRsmp0oXsmBOFRprFFwmhrxqOPZkW2WWWQM,50088
18
+ sgis/geopandas_tools/polygons_as_rings.py,sha256=BX_GZS6F9I4NbEpiOlNBd7zywJjdfdJVi_MkeONBuiM,14941
19
+ sgis/geopandas_tools/sfilter.py,sha256=SLcMYprQwnY5DNo0R7TGXk4m6u26H8o4PRn-RPhmeZY,9345
20
+ sgis/helpers.py,sha256=dscvGAbZyyncZbTL9qdsAHN6tb_T7SbNH7vM4ZrTeJw,8326
21
+ sgis/io/_is_dapla.py,sha256=o_qFD5GOi3dsSGOKmW6R8wZU0htVwFgRbGX7ppJCqT4,431
22
+ sgis/io/dapla_functions.py,sha256=Y69aSjnw6rOpH8yIquNor-JoTXcUfjbx2FcduT72-1A,17654
23
+ sgis/io/opener.py,sha256=BHyH7L8Ubh9C4Lsb8eBzGI6FLWg8UQFu-1bg3NEy_2k,862
24
+ sgis/io/read_parquet.py,sha256=FvZYv1rLkUlrSaUY6QW6E1yntmntTeQuZ9ZRgCDO4IM,3776
25
+ sgis/maps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ sgis/maps/examine.py,sha256=Pb0dH8JazU5E2svfQrzHO1Bi-sjy5SeyY6zoeMO34jE,9369
27
+ sgis/maps/explore.py,sha256=K-iJ07v_srUB_Z6hTuSRSKqgljKewY9A_j14bSrs0Yg,45916
28
+ sgis/maps/httpserver.py,sha256=7Od9JMCtntcIQKk_TchetojMHzFHT9sPw7GANahI97c,1982
29
+ sgis/maps/legend.py,sha256=1ZOhzftq1HRKlHphhfqUm82U-Kjx_xkACieLRevxke8,26232
30
+ sgis/maps/map.py,sha256=LHXFl_f5OWcPesKvwr-4L91Hd0VFFXNSGMQXaqmszMg,29276
31
+ sgis/maps/maps.py,sha256=GgvxwRY0Sz2e432Emj6i8hAp6sFduKt9VhsWw9HgKI4,23147
32
+ sgis/maps/thematicmap.py,sha256=bFlZy2xSKmEOHhvM0d1pv8O9JuNjR3P_9colTJnduvE,20729
33
+ sgis/maps/tilesources.py,sha256=aSci-0JURxnqqirIXQS5bHfNEIg3xfCM_B4gXs7GslM,2772
34
+ sgis/networkanalysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
+ sgis/networkanalysis/_get_route.py,sha256=9I3t9pnccUPr4mozy3TJCOpGCCf3UOIojmsbifubZbA,6368
36
+ sgis/networkanalysis/_od_cost_matrix.py,sha256=zkyPX7ObT996ahaFJ2oI0D0SqQWbWyfy_qLtXwValPg,3434
37
+ sgis/networkanalysis/_points.py,sha256=ajCy17dAmRq3bWRkNu_0LHreCVJ5Uh8DzAKWxyw7ipw,4481
38
+ sgis/networkanalysis/_service_area.py,sha256=jE0X54yS4eMfZYJXeKe_NgMKPDpau-05xWZaxDi_c6Y,5546
39
+ sgis/networkanalysis/closing_network_holes.py,sha256=EyhsLnjD6omTVgH9HIznukIX-vIOTtkv8_pwUnR6Pvk,12095
40
+ sgis/networkanalysis/cutting_lines.py,sha256=Uo6sGdC1xhkWwO69wgQYgGdT1JS6ZfZzHm8JrM1GmZM,15420
41
+ sgis/networkanalysis/directednetwork.py,sha256=Mrc2zHip4P5RNxnyffKm-xU832AVQeSHz-YZueAc0pM,11413
42
+ sgis/networkanalysis/finding_isolated_networks.py,sha256=s7knwQJeNqU6wJ9gIwwYnSAwGyKH98zZ2NroxZnTQxI,3637
43
+ sgis/networkanalysis/network.py,sha256=zV9bAbVdTgTohg2o2RFGy2uhOJrd3Ma57hwIAStxMAQ,7847
44
+ sgis/networkanalysis/networkanalysis.py,sha256=-g7slZLFNxUZSUMvVmf7zax-9IOXz1NGCtR6LcsBzBQ,68476
45
+ sgis/networkanalysis/networkanalysisrules.py,sha256=9sXigaCzvKhXFwpeVNMtOiIK3_Hzp9yDpFklmEEAPak,12956
46
+ sgis/networkanalysis/nodes.py,sha256=Yo0oWlsZO0Ex2_7lzGGUEiS2Ltfnm5kuCl5MkE2qJhA,6863
47
+ sgis/networkanalysis/traveling_salesman.py,sha256=Jjo6bHY4KJ-eK0LycyTy0sWxZjgITs5MBllZ_G9FhTE,5655
48
+ sgis/parallel/parallel.py,sha256=4Juv3oepguP4XryrgfbX-ipbYunKmbxvzM0jj8kYpCE,37296
49
+ sgis/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
+ sgis/raster/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
+ sgis/raster/base.py,sha256=8J6y9k-YuCAUpE83yTkg26RF2YCp9aieVvWrPi_GfUc,7697
52
+ sgis/raster/cube.py,sha256=P9baGN03Mwdi_LJ5a3F9_PROVYGCbjopQSxwQnr1LvE,41764
53
+ sgis/raster/cubebase.py,sha256=nao5huLer-nzy792PTZc0CKAMlmedZCe3siWnOf7Duw,639
54
+ sgis/raster/image_collection.py,sha256=ZLjoBIvSSLfKhgEm1GstbLsDPLhIUGPEbdE0GkngrtM,106271
55
+ sgis/raster/indices.py,sha256=bb0ItG8ePoFsrc5-XSupnMzJ6EwoALGh-lscM81Gpfo,3010
56
+ sgis/raster/raster.py,sha256=I8Af6gRIexvrNWTGBfZX6WC0Eug07Vykam4EaP1ZUws,50576
57
+ sgis/raster/sentinel_config.py,sha256=zcw24T9RBqix85QGK35LAYWuEkHJEwMcDRcnApRpLHs,3019
58
+ sgis/raster/zonal.py,sha256=st2mWiUcdxeEiHBOZSgFOnVcP6pc4EMPJBPw537Z4V8,3837
59
+ ssb_sgis-1.0.4.dist-info/LICENSE,sha256=np3IfD5m0ZUofn_kVzDZqliozuiO6wrktw3LRPjyEiI,1073
60
+ ssb_sgis-1.0.4.dist-info/METADATA,sha256=rtQ7B_Zrir7NlamabCImSEhhzSm_nMTbr4eqZhyWXHE,11772
61
+ ssb_sgis-1.0.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
62
+ ssb_sgis-1.0.4.dist-info/RECORD,,
File without changes
sgis/raster/torchgeo.py DELETED
@@ -1,171 +0,0 @@
1
- import glob
2
- import os
3
- import warnings
4
- from collections.abc import Callable
5
- from collections.abc import Iterable
6
- from typing import ClassVar
7
-
8
- import rasterio
9
- import rasterio.merge
10
- from rasterio.io import DatasetReader
11
- from rasterio.vrt import WarpedVRT
12
- from torchgeo.datasets.geo import RasterDataset
13
- from torchgeo.datasets.sentinel import Sentinel2 as TorchgeoSentinel2
14
-
15
- try:
16
- import dapla as dp
17
- except ImportError:
18
- pass
19
-
20
- try:
21
- from dapla.gcs import GCSFileSystem
22
- except ImportError:
23
-
24
- class GCSFileSystem:
25
- """Placeholder."""
26
-
27
-
28
- try:
29
- from gcsfs.core import GCSFile
30
- except ImportError:
31
-
32
- class GCSFile:
33
- """Placeholder."""
34
-
35
-
36
- from ..io._is_dapla import is_dapla
37
- from ..io.opener import opener
38
-
39
- SENTINEL2_FILENAME_REGEX = r"""
40
- ^SENTINEL2X_
41
- (?P<date>\d{8})
42
- .*T(?P<tile>\d{2}[A-Z]{3})
43
- .*(?:_(?P<resolution>{}m))?
44
- .*(?P<band>B\d{1,2}A|B\d{1,2})
45
- .*\..*$
46
- """
47
-
48
- SENTINEL_2_BANDS = [
49
- # "B1",
50
- "B2",
51
- "B3",
52
- "B4",
53
- "B5",
54
- "B6",
55
- "B7",
56
- "B8",
57
- "B8A",
58
- # "B9",
59
- # "B10",
60
- "B11",
61
- "B12",
62
- ]
63
- SENTINEL_2_RBG_BANDS = ["B4", "B3", "B2"]
64
-
65
-
66
- class GCSRasterDataset(RasterDataset):
67
- """Wrapper around torchgeo's RasterDataset that works in and outside of Dapla (stat norway)."""
68
-
69
- def __init__(self, *args, **kwargs) -> None:
70
- """Initialiser. Args and kwargs passed to torchgeo.datasets.geo.RasterDataset."""
71
- super().__init__(*args, **kwargs)
72
- if is_dapla():
73
- [file.close() for file in self.files]
74
-
75
- @property
76
- def files(self) -> set[GCSFile] | set[str]:
77
- """A list of all files in the dataset.
78
-
79
- Returns:
80
- All files in the dataset.
81
- """
82
- if isinstance(self.paths, str):
83
- paths: list[str] = [self.paths]
84
- else:
85
- paths = self.paths
86
-
87
- if is_dapla():
88
- fs = dp.FileClient.get_gcs_file_system()
89
- files: set[GCSFile] = {
90
- fs.open(x)
91
- for x in _get_gcs_paths(
92
- paths, filename_glob=self.filename_glob, file_system=fs
93
- )
94
- }
95
- return files
96
-
97
- # Using set to remove any duplicates if directories are overlapping
98
- files: set[str] = set()
99
- for path in paths:
100
- if os.path.isdir(path):
101
- pathname = os.path.join(path, "**", self.filename_glob)
102
- files |= {
103
- x for x in glob.iglob(pathname, recursive=True) if os.path.isfile(x)
104
- }
105
- elif os.path.isfile(path):
106
- files.add(path)
107
- else:
108
- warnings.warn(
109
- f"Could not find any relevant files for provided path '{path}'. "
110
- f"Path was ignored.",
111
- UserWarning,
112
- stacklevel=1,
113
- )
114
-
115
- return files
116
-
117
- def _load_warp_file(self, filepath: str) -> DatasetReader:
118
- """Load and warp a file to the correct CRS and resolution.
119
-
120
- Args:
121
- filepath: file to load and warp.
122
-
123
- Returns:
124
- file handle of warped VRT.
125
- """
126
- with opener(filepath) as f:
127
- src = rasterio.open(f)
128
-
129
- # Only warp if necessary
130
- if src.crs != self.crs:
131
- vrt = WarpedVRT(src, crs=self.crs)
132
- src.close()
133
- return vrt
134
- else:
135
- return src
136
-
137
-
138
- def _get_gcs_paths(
139
- paths: str | Iterable[str],
140
- filename_glob: str,
141
- file_system: GCSFileSystem | None = None,
142
- ) -> set[str]:
143
- if file_system is None:
144
- file_system = dp.FileClient.get_gcs_file_system()
145
-
146
- # Using set to remove any duplicates if directories are overlapping
147
- out_paths: set[str] = set()
148
- for path in paths:
149
- pathname = os.path.join(path, "**", filename_glob)
150
- if is_dapla():
151
- out_paths |= {
152
- x for x in file_system.glob(pathname, recursive=True) if "." in x
153
- }
154
- return out_paths
155
-
156
-
157
- class Sentinel2(GCSRasterDataset):
158
- """Works like torchgeo's Sentinel2, with custom regexes."""
159
-
160
- date_format: ClassVar[str] = "%Y%m%d"
161
- filename_glob: ClassVar[str] = "SENTINEL2X_*_*.*"
162
-
163
- filename_regex: ClassVar[str] = SENTINEL2_FILENAME_REGEX
164
- all_bands: ClassVar[list[str]] = SENTINEL_2_BANDS
165
- rgb_bands: ClassVar[list[str]] = SENTINEL_2_RBG_BANDS
166
-
167
- separate_files: ClassVar[bool] = True
168
-
169
- cmap: ClassVar[dict[int, tuple[int, int, int, int]]] = {}
170
-
171
- plot: Callable = TorchgeoSentinel2.plot
@@ -1,61 +0,0 @@
1
- sgis/__init__.py,sha256=z78RVVd1xmvTVndEHOs3TUK-8kYf95t0rEkKY8fVuE8,6519
2
- sgis/exceptions.py,sha256=A5Jtx_AtIUaTuWQ2wJh7y1it6-HbXHXip5PTrl6l0dk,658
3
- sgis/geopandas_tools/__init__.py,sha256=bo8lFMcltOz7TtWAi52_ekR2gd3mjfBfKeMDV5zuqFY,28
4
- sgis/geopandas_tools/bounds.py,sha256=60gtB83tyyTq4fayTgya-KocsRts6XXZQVfoHQ4FDGc,23846
5
- sgis/geopandas_tools/buffer_dissolve_explode.py,sha256=b17S4-4VxSCnRp76fsObgWCcfUQU3hfHf3YZ1gnXEqE,18303
6
- sgis/geopandas_tools/centerlines.py,sha256=qTLUWOAgLT_E7ow4cZjWgwgH2BqaEh-hSQivXQbxWcc,14435
7
- sgis/geopandas_tools/cleaning.py,sha256=w0puDL7RfIZwWy_wRxXkgfYTHQKZVBxKvAhbjsnAqSY,23772
8
- sgis/geopandas_tools/conversion.py,sha256=BSyc4sp36CB8fYEgspAJY2gJPvgukL-75FX0vjdzkPI,24062
9
- sgis/geopandas_tools/duplicates.py,sha256=TIOxfyK3KflwixxOo6cVaYDoo_jFXEwdMiTAW8Js4bw,13596
10
- sgis/geopandas_tools/general.py,sha256=MryYBJQ-pU8jbllLx1iXhbHXv6dqhd_5AjK6buGeBuc,25944
11
- sgis/geopandas_tools/geocoding.py,sha256=n47aFQMm4yX1MsPnTM4dFjwegCA1ZmGUDj1uyu7OJV4,691
12
- sgis/geopandas_tools/geometry_types.py,sha256=-bFKz0j4WHWv0bTP8emcP8RrYBMtlKX7VpniukX7f14,7586
13
- sgis/geopandas_tools/neighbors.py,sha256=Ox3efpTeR7rtmD1tZtCi6xMiSYUhUvYBzMFrlCR5ZhQ,16363
14
- sgis/geopandas_tools/overlay.py,sha256=yAIpM1Yq9JBjRMhoetxiJXdwpjHF_q4tkYNhatYJQS0,25509
15
- sgis/geopandas_tools/point_operations.py,sha256=kwbJAG7sKnPns4_L-xI3fZ04dlWr6Gu3cGtYtivetSY,6959
16
- sgis/geopandas_tools/polygon_operations.py,sha256=ueOoB96TYUSYMTWDLhSfVvUef6AHq1CsvzytZV-0M4s,37224
17
- sgis/geopandas_tools/polygons_as_rings.py,sha256=26_TSB3dyzsPHc4h2RVzhwFVBa9qG1mw9xLGZbNKOMU,13558
18
- sgis/geopandas_tools/sfilter.py,sha256=hj-RpGIawjxlf1n780aJZ6UHPHJ3W8WE6BZJqLYKOzs,8653
19
- sgis/helpers.py,sha256=iWsVzypu92kQ89t3Og5BO1w2T4sYhseExVH0i0VzPFI,8294
20
- sgis/io/_is_dapla.py,sha256=o_qFD5GOi3dsSGOKmW6R8wZU0htVwFgRbGX7ppJCqT4,431
21
- sgis/io/dapla_functions.py,sha256=IHB8Nhg90ui_o6IvKx-BjAS3mciruCClL-v-JQNfg4M,8807
22
- sgis/io/opener.py,sha256=BHyH7L8Ubh9C4Lsb8eBzGI6FLWg8UQFu-1bg3NEy_2k,862
23
- sgis/io/read_parquet.py,sha256=1mQ-c9zHC91DWAMS2a7tU7xzx3aa4-USoMhChNK3ryU,3775
24
- sgis/maps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
- sgis/maps/examine.py,sha256=WVCRYqDULnqyiGJS01XYpsdZI8FklLJuzE9RVcK1Bgk,8708
26
- sgis/maps/explore.py,sha256=cyLD7Ix0vacHdYB6Q93yjcan_rTbXlNJGosRh4E0zOE,33284
27
- sgis/maps/httpserver.py,sha256=7Od9JMCtntcIQKk_TchetojMHzFHT9sPw7GANahI97c,1982
28
- sgis/maps/legend.py,sha256=55PtIr4GUQSObKfAd2XLUTUTSbxrQ6PEafZUosjiOL0,24329
29
- sgis/maps/map.py,sha256=b2LYY4lZ0wN73yvuYKw2TNweB0NapbF2XywvgoyXY48,25234
30
- sgis/maps/maps.py,sha256=EshVwPVnjTQMbOeWTVmdFn-Ep2NMHztXNadqcHAVjJU,20582
31
- sgis/maps/thematicmap.py,sha256=uhg6WLx5-RJD0qSxnp5HYP9r3PvhWbmEu8CCHYz-HG8,14764
32
- sgis/maps/tilesources.py,sha256=aSci-0JURxnqqirIXQS5bHfNEIg3xfCM_B4gXs7GslM,2772
33
- sgis/networkanalysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
- sgis/networkanalysis/_get_route.py,sha256=9I3t9pnccUPr4mozy3TJCOpGCCf3UOIojmsbifubZbA,6368
35
- sgis/networkanalysis/_od_cost_matrix.py,sha256=zkyPX7ObT996ahaFJ2oI0D0SqQWbWyfy_qLtXwValPg,3434
36
- sgis/networkanalysis/_points.py,sha256=ajCy17dAmRq3bWRkNu_0LHreCVJ5Uh8DzAKWxyw7ipw,4481
37
- sgis/networkanalysis/_service_area.py,sha256=BzqB8X5X5CGexUwbpP379jEj-ad4mgCzFr8mOa-BsnY,5385
38
- sgis/networkanalysis/closing_network_holes.py,sha256=R6NFm97eWiIN0K_HfOd8ytI9maBRXEe2kAmfKpvFTi4,12093
39
- sgis/networkanalysis/cutting_lines.py,sha256=E2cwS4aAgap37uls_qfDR-I8p5IVrH1foRpBmTB_nVo,15191
40
- sgis/networkanalysis/directednetwork.py,sha256=FVxaSKSeWoeJSI_mMU6SA5ZIqsvBlI7dZynqsbGeGSU,11412
41
- sgis/networkanalysis/finding_isolated_networks.py,sha256=xoDmJBBNp53oo8zh5818vNrkpEbF4MJZup4PsTVTBJE,3382
42
- sgis/networkanalysis/network.py,sha256=zV9bAbVdTgTohg2o2RFGy2uhOJrd3Ma57hwIAStxMAQ,7847
43
- sgis/networkanalysis/networkanalysis.py,sha256=u86cApLFW1hYYz4YyDz5629_vKBbCwoQsHiz5A_pV5E,68444
44
- sgis/networkanalysis/networkanalysisrules.py,sha256=20Xkawv7vs-YnTKTXJbW3gVgxqD3OFrVn0nFBBx7uRY,12955
45
- sgis/networkanalysis/nodes.py,sha256=Yo0oWlsZO0Ex2_7lzGGUEiS2Ltfnm5kuCl5MkE2qJhA,6863
46
- sgis/networkanalysis/traveling_salesman.py,sha256=pzEurmons3_SaFH_zbQ5sRyE27L86XkvPTFEyLeOXZ0,5654
47
- sgis/parallel/parallel.py,sha256=WU55duAf_RKaBbk6pzkMDfw3ZakkHPvqPD6399FxOYA,36002
48
- sgis/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
- sgis/raster/__init__.py,sha256=q7AWZko7RvC3eFnpejrnU7HF5jCyJDmoiOrI11DD32E,175
50
- sgis/raster/base.py,sha256=POu3uZJqygubLGh9t_lQJe8pNKQ9MD9wHubFHC8_nck,1192
51
- sgis/raster/cube.py,sha256=UZ_fcQAsSmk9YkHx6ldy7199jPqaly6mReRgkl0WE6k,40419
52
- sgis/raster/cubebase.py,sha256=nao5huLer-nzy792PTZc0CKAMlmedZCe3siWnOf7Duw,639
53
- sgis/raster/indices.py,sha256=pEtfTsfH6IKGAT1R_x-rrqx10yoqLaB73uRWRiDjy_Y,2703
54
- sgis/raster/methods_as_functions.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
- sgis/raster/raster.py,sha256=1hXBy2JPVC80ymjvj51o9MaeHCWsugv_ld1x3VLPHoA,53765
56
- sgis/raster/torchgeo.py,sha256=KpPb91bFzbqcm089NHtiWwyUyz1uBG5KxwGFZfiNhu4,4523
57
- sgis/raster/zonal.py,sha256=UJkCC93_UfJ113HmWt9lnlsR1mfs1d7Lioh-dK8fj7o,3862
58
- ssb_sgis-1.0.2.dist-info/LICENSE,sha256=np3IfD5m0ZUofn_kVzDZqliozuiO6wrktw3LRPjyEiI,1073
59
- ssb_sgis-1.0.2.dist-info/METADATA,sha256=5DDIE7r1tXk1WVgrDMQSdh6FOVRstx-WS0waNN0hhBM,11780
60
- ssb_sgis-1.0.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
61
- ssb_sgis-1.0.2.dist-info/RECORD,,