ssb-sgis 1.3.0__py3-none-any.whl → 1.3.2__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.
- sgis/geopandas_tools/bounds.py +4 -2
- sgis/io/dapla_functions.py +4 -2
- sgis/maps/norge_i_bilder.json +9518 -656
- sgis/maps/wms.py +9 -8
- sgis/raster/image_collection.py +24 -12
- {ssb_sgis-1.3.0.dist-info → ssb_sgis-1.3.2.dist-info}/METADATA +1 -1
- {ssb_sgis-1.3.0.dist-info → ssb_sgis-1.3.2.dist-info}/RECORD +9 -9
- {ssb_sgis-1.3.0.dist-info → ssb_sgis-1.3.2.dist-info}/LICENSE +0 -0
- {ssb_sgis-1.3.0.dist-info → ssb_sgis-1.3.2.dist-info}/WHEEL +0 -0
sgis/maps/wms.py
CHANGED
|
@@ -27,11 +27,6 @@ from ..geopandas_tools.conversion import to_shapely
|
|
|
27
27
|
from ..geopandas_tools.sfilter import sfilter
|
|
28
28
|
from ..raster.image_collection import Band
|
|
29
29
|
|
|
30
|
-
JSON_PATH = Path(__file__).parent / "norge_i_bilder.json"
|
|
31
|
-
|
|
32
|
-
# JSON_YEARS = tuple(range(1900, datetime.datetime.now().year + 1))
|
|
33
|
-
JSON_YEARS = tuple(range(2006, datetime.datetime.now().year + 1))
|
|
34
|
-
|
|
35
30
|
DEFAULT_YEARS: tuple[int] = tuple(
|
|
36
31
|
range(
|
|
37
32
|
int(datetime.datetime.now().year) - 10,
|
|
@@ -100,6 +95,8 @@ class NorgeIBilderWms(WmsLoader):
|
|
|
100
95
|
"""
|
|
101
96
|
|
|
102
97
|
url: str = "https://wms.geonorge.no/skwms1/wms.nib-prosjekter"
|
|
98
|
+
_min_year: int = 1935
|
|
99
|
+
_json_path = Path(__file__).parent / "norge_i_bilder.json"
|
|
103
100
|
|
|
104
101
|
def __init__(
|
|
105
102
|
self,
|
|
@@ -116,7 +113,7 @@ class NorgeIBilderWms(WmsLoader):
|
|
|
116
113
|
self.show = show
|
|
117
114
|
self._use_json = _use_json
|
|
118
115
|
|
|
119
|
-
if self._use_json
|
|
116
|
+
if self._use_json:
|
|
120
117
|
self._load_from_json()
|
|
121
118
|
else:
|
|
122
119
|
self._tiles = None
|
|
@@ -132,8 +129,12 @@ class NorgeIBilderWms(WmsLoader):
|
|
|
132
129
|
r"<northBoundLatitude>(.*?)</northBoundLatitude>.*?</EX_GeographicBoundingBox>"
|
|
133
130
|
)
|
|
134
131
|
|
|
132
|
+
url: str = (
|
|
133
|
+
"https://wms.geonorge.no/skwms1/wms.nib-prosjekter?SERVICE=WMS&REQUEST=GetCapabilities"
|
|
134
|
+
)
|
|
135
|
+
|
|
135
136
|
all_tiles: list[dict] = []
|
|
136
|
-
with urlopen(
|
|
137
|
+
with urlopen(url) as file:
|
|
137
138
|
xml_data: str = file.read().decode("utf-8")
|
|
138
139
|
|
|
139
140
|
for text in xml_data.split('<Layer queryable="1">')[1:]:
|
|
@@ -333,7 +334,7 @@ class NorgeIBilderWms(WmsLoader):
|
|
|
333
334
|
def _load_from_json(self) -> None:
|
|
334
335
|
"""Load tiles from json file."""
|
|
335
336
|
try:
|
|
336
|
-
with open(
|
|
337
|
+
with open(self._json_path, encoding="utf-8") as file:
|
|
337
338
|
self._tiles = json.load(file)
|
|
338
339
|
except FileNotFoundError:
|
|
339
340
|
self._tiles = None
|
sgis/raster/image_collection.py
CHANGED
|
@@ -373,6 +373,10 @@ class ImageCollectionGroupBy:
|
|
|
373
373
|
"""Iterate over the group values and the ImageCollection groups themselves."""
|
|
374
374
|
return iter(self.data)
|
|
375
375
|
|
|
376
|
+
def __reversed__(self) -> Iterator[tuple[tuple[Any, ...], "ImageCollection"]]:
|
|
377
|
+
"""Iterate over the group values and the ImageCollection groups themselves."""
|
|
378
|
+
return iter(reversed(self.data))
|
|
379
|
+
|
|
376
380
|
def __len__(self) -> int:
|
|
377
381
|
"""Number of ImageCollection groups."""
|
|
378
382
|
return len(self.data)
|
|
@@ -573,9 +577,7 @@ class _ImageBase:
|
|
|
573
577
|
Used in __init__ to select relevant paths fast.
|
|
574
578
|
"""
|
|
575
579
|
df = pd.DataFrame({"file_path": list(file_paths)})
|
|
576
|
-
|
|
577
580
|
df["file_name"] = df["file_path"].apply(lambda x: Path(x).name)
|
|
578
|
-
|
|
579
581
|
df["image_path"] = df["file_path"].apply(
|
|
580
582
|
lambda x: _fix_path(str(Path(x).parent))
|
|
581
583
|
)
|
|
@@ -605,12 +607,10 @@ class _ImageBase:
|
|
|
605
607
|
grouped["imagename"] = grouped["image_path"].apply(
|
|
606
608
|
lambda x: _fix_path(Path(x).name)
|
|
607
609
|
)
|
|
608
|
-
|
|
609
610
|
if self.image_patterns and len(grouped):
|
|
610
611
|
grouped = _get_regexes_matches_for_df(
|
|
611
612
|
grouped, "imagename", self.image_patterns
|
|
612
613
|
)
|
|
613
|
-
|
|
614
614
|
return grouped
|
|
615
615
|
|
|
616
616
|
def copy(self) -> "_ImageBase":
|
|
@@ -1498,6 +1498,7 @@ class Image(_ImageBandBase):
|
|
|
1498
1498
|
df: pd.DataFrame | None = None,
|
|
1499
1499
|
nodata: int | None = None,
|
|
1500
1500
|
all_file_paths: list[str] | None = None,
|
|
1501
|
+
use_json_metadata: bool = True,
|
|
1501
1502
|
**kwargs,
|
|
1502
1503
|
) -> None:
|
|
1503
1504
|
"""Image initialiser."""
|
|
@@ -1539,9 +1540,12 @@ class Image(_ImageBandBase):
|
|
|
1539
1540
|
else:
|
|
1540
1541
|
self._all_file_paths = None
|
|
1541
1542
|
|
|
1542
|
-
if
|
|
1543
|
-
|
|
1544
|
-
|
|
1543
|
+
if use_json_metadata and (
|
|
1544
|
+
self.metadata is None
|
|
1545
|
+
or (
|
|
1546
|
+
not len(self.metadata)
|
|
1547
|
+
and "metadata.json" in {Path(x).name for x in self._all_file_paths}
|
|
1548
|
+
)
|
|
1545
1549
|
):
|
|
1546
1550
|
with _open_func(
|
|
1547
1551
|
next(
|
|
@@ -2191,7 +2195,7 @@ class ImageCollection(_ImageBase):
|
|
|
2191
2195
|
index_aligned_kwargs: dict | None = None,
|
|
2192
2196
|
masked: bool = True,
|
|
2193
2197
|
processes: int | None = None,
|
|
2194
|
-
) ->
|
|
2198
|
+
) -> PixelwiseResults:
|
|
2195
2199
|
"""Run a function for each pixel.
|
|
2196
2200
|
|
|
2197
2201
|
The function should take a 1d array as first argument. This will be
|
|
@@ -2218,7 +2222,7 @@ class ImageCollection(_ImageBase):
|
|
|
2218
2222
|
):
|
|
2219
2223
|
mask_array = np.array(
|
|
2220
2224
|
[
|
|
2221
|
-
(band.values.mask) | (band.values.data == self.nodata)
|
|
2225
|
+
(band.values.mask) # | (band.values.data == self.nodata)
|
|
2222
2226
|
for img in self
|
|
2223
2227
|
for band in img
|
|
2224
2228
|
]
|
|
@@ -2680,10 +2684,18 @@ class ImageCollection(_ImageBase):
|
|
|
2680
2684
|
if self._images is None:
|
|
2681
2685
|
return self
|
|
2682
2686
|
|
|
2687
|
+
if not hasattr(other, "crs") or other.crs is None:
|
|
2688
|
+
try:
|
|
2689
|
+
crs = self.crs
|
|
2690
|
+
except ValueError as e:
|
|
2691
|
+
raise ValueError("Cannot filter bounds by object without crs") from e
|
|
2692
|
+
else:
|
|
2693
|
+
crs = other.crs
|
|
2683
2694
|
other = to_shapely(other)
|
|
2684
2695
|
|
|
2696
|
+
union_func = functools.partial(_union_all_and_to_crs, crs=crs)
|
|
2685
2697
|
with ThreadPoolExecutor() as executor:
|
|
2686
|
-
bounds_iterable: Generator[Polygon] = executor.map(
|
|
2698
|
+
bounds_iterable: Generator[Polygon] = executor.map(union_func, self)
|
|
2687
2699
|
|
|
2688
2700
|
intersects_list: pd.Series = GeoSeries(list(bounds_iterable)).intersects(other)
|
|
2689
2701
|
|
|
@@ -3426,8 +3438,8 @@ def _open_raster(path: str | Path) -> rasterio.io.DatasetReader:
|
|
|
3426
3438
|
return rasterio.open(file)
|
|
3427
3439
|
|
|
3428
3440
|
|
|
3429
|
-
def
|
|
3430
|
-
return obj.union_all()
|
|
3441
|
+
def _union_all_and_to_crs(obj: _ImageBase, crs) -> Polygon:
|
|
3442
|
+
return GeoSeries([obj.union_all()], crs=obj.crs).to_crs(crs).union_all()
|
|
3431
3443
|
|
|
3432
3444
|
|
|
3433
3445
|
def _read_mask_array(self: Band | Image, **kwargs) -> np.ndarray:
|
|
@@ -3,7 +3,7 @@ sgis/conf.py,sha256=pLqmvIKoKmXoW8chja3iQpbDUp9Z39vzl97MGH8ZHW0,2614
|
|
|
3
3
|
sgis/debug_config.py,sha256=Tfr19kU46hSkkspsIJcrUWvlhaL4U3-f8xEPkujSCAQ,593
|
|
4
4
|
sgis/exceptions.py,sha256=WNaEBPNNx0rmz-YDzlFX4vIE7ocJQruUTqS2RNAu2zU,660
|
|
5
5
|
sgis/geopandas_tools/__init__.py,sha256=bo8lFMcltOz7TtWAi52_ekR2gd3mjfBfKeMDV5zuqFY,28
|
|
6
|
-
sgis/geopandas_tools/bounds.py,sha256=
|
|
6
|
+
sgis/geopandas_tools/bounds.py,sha256=Os9o4EZ1ax38reW-9cdJzgKHoX2il9lUEIZ7wc5CpBQ,23997
|
|
7
7
|
sgis/geopandas_tools/buffer_dissolve_explode.py,sha256=z9HvakazR_prXH862e8-gEe7UFbeI4rRTbUaBgPeMBk,19552
|
|
8
8
|
sgis/geopandas_tools/centerlines.py,sha256=Q65Sx01SeAlulBEd9oaZkB2maBBNdLcJwAbTILg4SPU,11848
|
|
9
9
|
sgis/geopandas_tools/cleaning.py,sha256=fST0xFztmyn-QUOAfvjZmu7aO_zPiolWK7gd7TR6ffI,24393
|
|
@@ -23,7 +23,7 @@ sgis/geopandas_tools/utils.py,sha256=X0pRvB1tWgV_0BCrRS1HU9LtLGnZCpvVPxyqM9JGb0Y
|
|
|
23
23
|
sgis/helpers.py,sha256=4N6vFWQ3TYVzRHNcWY_fNa_GkFuaZB3vtCkkFND-qs0,9628
|
|
24
24
|
sgis/io/__init__.py,sha256=uyBr20YDqB2bQttrd5q1JuGOvX32A-MSvS7Wmw5f5qg,177
|
|
25
25
|
sgis/io/_is_dapla.py,sha256=wmfkSe98IrLhUg3dtXZusV6OVC8VlY1kbc5EQDf3P-Q,358
|
|
26
|
-
sgis/io/dapla_functions.py,sha256=
|
|
26
|
+
sgis/io/dapla_functions.py,sha256=ZWtUv58GY0RowUGY7vJBk1rrpjoZq8iVZEmSV3GJShU,31883
|
|
27
27
|
sgis/io/opener.py,sha256=HWO3G1NB6bpXKM94JadCD513vjat1o1TFjWGWzyVasg,898
|
|
28
28
|
sgis/io/read_parquet.py,sha256=FvZYv1rLkUlrSaUY6QW6E1yntmntTeQuZ9ZRgCDO4IM,3776
|
|
29
29
|
sgis/maps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -33,10 +33,10 @@ sgis/maps/httpserver.py,sha256=I7tTn3hFaTCc-E-T_o9v0nXwMGaS2Xqd4MlWbq8k-J4,3014
|
|
|
33
33
|
sgis/maps/legend.py,sha256=gTEWCVIZH1cw6ULVVrJqRR4__uOZvrT3xxQ5lhZMVR4,26899
|
|
34
34
|
sgis/maps/map.py,sha256=iGa0o7NlUMErJCYJpVzkpDvuWJc8iDN_-tH2X2WcBlI,30802
|
|
35
35
|
sgis/maps/maps.py,sha256=fLK5WUlQ2YTm7t-8260lYxCFvpZN6j0Y-bVYCyv8NAY,23249
|
|
36
|
-
sgis/maps/norge_i_bilder.json,sha256=
|
|
36
|
+
sgis/maps/norge_i_bilder.json,sha256=wUYY8VTanI-C4bpNk7bmnQb8S-S3CBUIRLgdOoydnoQ,20197311
|
|
37
37
|
sgis/maps/thematicmap.py,sha256=ZtV4Hfylr1ST_cPzi11_lFIsTdY3D1o1EZQbPXZLwyM,25187
|
|
38
38
|
sgis/maps/tilesources.py,sha256=F4mFHxPwkiPJdVKzNkScTX6xbJAMIUtlTq4mQ83oguw,1746
|
|
39
|
-
sgis/maps/wms.py,sha256=
|
|
39
|
+
sgis/maps/wms.py,sha256=sCVpKxH1Rsd14GECW7BFh8yaWngpVWYvw9Yhuez1yW8,12482
|
|
40
40
|
sgis/networkanalysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
41
41
|
sgis/networkanalysis/_get_route.py,sha256=3m5xQdQqGtt51vcI5fcmYQAOQCeBtL6sorDoPxBNf84,7818
|
|
42
42
|
sgis/networkanalysis/_od_cost_matrix.py,sha256=zkyPX7ObT996ahaFJ2oI0D0SqQWbWyfy_qLtXwValPg,3434
|
|
@@ -56,12 +56,12 @@ sgis/parallel/parallel.py,sha256=V7O5mEZdfJpcOPrmn2H4bEGtbzA0FggjQ8dGhznjr80,400
|
|
|
56
56
|
sgis/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
57
57
|
sgis/raster/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
58
58
|
sgis/raster/base.py,sha256=8JdXXDj8CgJQt5WIkkNbpM5U0pYyQrWQY9dszfUaUQ4,7743
|
|
59
|
-
sgis/raster/image_collection.py,sha256=
|
|
59
|
+
sgis/raster/image_collection.py,sha256=ZWAJzL8CQOMqlDlyZ5idZlWZRnlL0wmnryPwXww7Z1Y,122584
|
|
60
60
|
sgis/raster/indices.py,sha256=efJmgfPg_VuSzXFosXV661IendF8CwPFWtMhyP4TMUg,222
|
|
61
61
|
sgis/raster/regex.py,sha256=4idTJ9vFtsGtbxcjJrx2VrpJJuDMP3bLdqF93Vc_cmY,3752
|
|
62
62
|
sgis/raster/sentinel_config.py,sha256=nySDqn2R8M6W8jguoBeSAK_zzbAsqmaI59i32446FwY,1268
|
|
63
63
|
sgis/raster/zonal.py,sha256=D4Gyptw-yOLTCO41peIuYbY-DANsJCG19xXDlf1QAz4,2299
|
|
64
|
-
ssb_sgis-1.3.
|
|
65
|
-
ssb_sgis-1.3.
|
|
66
|
-
ssb_sgis-1.3.
|
|
67
|
-
ssb_sgis-1.3.
|
|
64
|
+
ssb_sgis-1.3.2.dist-info/LICENSE,sha256=np3IfD5m0ZUofn_kVzDZqliozuiO6wrktw3LRPjyEiI,1073
|
|
65
|
+
ssb_sgis-1.3.2.dist-info/METADATA,sha256=bXRithGOpGcmOzDI1FkZ-trISx9unb2erI1XXwfa91w,11624
|
|
66
|
+
ssb_sgis-1.3.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
67
|
+
ssb_sgis-1.3.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|