ssb-sgis 1.0.13__py3-none-any.whl → 1.0.15__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/__init__.py +1 -0
- sgis/maps/explore.py +19 -1
- sgis/maps/maps.py +15 -0
- sgis/maps/norge_i_bilder.json +11517 -0
- sgis/maps/wms.py +187 -0
- {ssb_sgis-1.0.13.dist-info → ssb_sgis-1.0.15.dist-info}/METADATA +1 -1
- {ssb_sgis-1.0.13.dist-info → ssb_sgis-1.0.15.dist-info}/RECORD +9 -7
- {ssb_sgis-1.0.13.dist-info → ssb_sgis-1.0.15.dist-info}/LICENSE +0 -0
- {ssb_sgis-1.0.13.dist-info → ssb_sgis-1.0.15.dist-info}/WHEEL +0 -0
sgis/__init__.py
CHANGED
|
@@ -99,6 +99,7 @@ from .maps.maps import samplemap
|
|
|
99
99
|
from .maps.thematicmap import ThematicMap
|
|
100
100
|
from .maps.tilesources import kartverket as kartverket_tiles
|
|
101
101
|
from .maps.tilesources import xyz as xyztiles
|
|
102
|
+
from .maps.wms import NorgeIBilderWms
|
|
102
103
|
from .networkanalysis.closing_network_holes import close_network_holes
|
|
103
104
|
from .networkanalysis.closing_network_holes import close_network_holes_to_deadends
|
|
104
105
|
from .networkanalysis.closing_network_holes import get_k_nearest_points_for_deadends
|
sgis/maps/explore.py
CHANGED
|
@@ -44,6 +44,7 @@ from ..geopandas_tools.general import clean_geoms
|
|
|
44
44
|
from ..geopandas_tools.general import make_all_singlepart
|
|
45
45
|
from ..geopandas_tools.geometry_types import get_geom_type
|
|
46
46
|
from ..geopandas_tools.geometry_types import to_single_geom_type
|
|
47
|
+
from .wms import WmsLoader
|
|
47
48
|
|
|
48
49
|
try:
|
|
49
50
|
from ..raster.image_collection import Band
|
|
@@ -157,7 +158,9 @@ def to_tile(tile: str | xyzservices.TileProvider, max_zoom: int) -> folium.TileL
|
|
|
157
158
|
except TypeError:
|
|
158
159
|
name = tile
|
|
159
160
|
|
|
160
|
-
if not isinstance(tile,
|
|
161
|
+
if isinstance(tile, folium.map.Layer) and not isinstance(tile, folium.GeoJson):
|
|
162
|
+
return tile
|
|
163
|
+
elif not isinstance(tile, str):
|
|
161
164
|
try:
|
|
162
165
|
return folium.TileLayer(tile, name=name, max_zoom=max_zoom)
|
|
163
166
|
except TypeError:
|
|
@@ -277,6 +280,7 @@ class Explore(Map):
|
|
|
277
280
|
max_images: int = 10,
|
|
278
281
|
max_nodata_percentage: int = 100,
|
|
279
282
|
display: bool = True,
|
|
283
|
+
wms: WmsLoader | None = None,
|
|
280
284
|
**kwargs,
|
|
281
285
|
) -> None:
|
|
282
286
|
"""Initialiser.
|
|
@@ -306,6 +310,7 @@ class Explore(Map):
|
|
|
306
310
|
max_nodata_percentage: Maximum percentage nodata values (e.g. clouds) ro allow in
|
|
307
311
|
image arrays.
|
|
308
312
|
display: Whether to display the map interactively.
|
|
313
|
+
wms: A WmsLoader instance for loading image tiles as layers. E.g. NorgeIBilderWms.
|
|
309
314
|
**kwargs: Additional keyword arguments. Can also be geometry-like objects
|
|
310
315
|
where the key is the label.
|
|
311
316
|
"""
|
|
@@ -322,6 +327,7 @@ class Explore(Map):
|
|
|
322
327
|
self.max_images = max_images
|
|
323
328
|
self.max_nodata_percentage = max_nodata_percentage
|
|
324
329
|
self.display = display
|
|
330
|
+
self.wms = [wms] if isinstance(wms, WmsLoader) else wms
|
|
325
331
|
self.legend = None
|
|
326
332
|
|
|
327
333
|
self.browser = browser
|
|
@@ -760,6 +766,12 @@ class Explore(Map):
|
|
|
760
766
|
for tile in tiles:
|
|
761
767
|
to_tile(tile, max_zoom=self.max_zoom).add_to(mapobj)
|
|
762
768
|
|
|
769
|
+
def _add_wms(self, map_: folium.Map, bbox: Any) -> None:
|
|
770
|
+
for wms in self.wms:
|
|
771
|
+
tiles = wms.get_tiles(bbox, max_zoom=self.max_zoom)
|
|
772
|
+
for tile in tiles.values():
|
|
773
|
+
map_.add_child(tile)
|
|
774
|
+
|
|
763
775
|
def _create_continous_map(self):
|
|
764
776
|
self._prepare_continous_map()
|
|
765
777
|
if self.scheme:
|
|
@@ -966,6 +978,9 @@ class Explore(Map):
|
|
|
966
978
|
m.get_root().add_child(style)
|
|
967
979
|
# folium.LayerControl(collapsed=False).add_to(m)
|
|
968
980
|
|
|
981
|
+
if self.wms:
|
|
982
|
+
self._add_wms(m, bounds)
|
|
983
|
+
|
|
969
984
|
return m
|
|
970
985
|
|
|
971
986
|
def _make_geojson(
|
|
@@ -1112,6 +1127,7 @@ class Explore(Map):
|
|
|
1112
1127
|
highlight_function=highlight_function,
|
|
1113
1128
|
smooth_factor=self.smooth_factor,
|
|
1114
1129
|
show=show,
|
|
1130
|
+
# on_each_feature="function(feature,layer){layer.bindTooltip(feature.properties.NAME,{permanent:true,direction:'center'});return layer;}",
|
|
1115
1131
|
**kwargs,
|
|
1116
1132
|
)
|
|
1117
1133
|
|
|
@@ -1141,6 +1157,8 @@ def _tooltip_popup(
|
|
|
1141
1157
|
return folium.GeoJsonTooltip(fields, **kwargs)
|
|
1142
1158
|
elif type_ == "popup":
|
|
1143
1159
|
return folium.GeoJsonPopup(fields, **kwargs)
|
|
1160
|
+
else:
|
|
1161
|
+
raise ValueError(type_)
|
|
1144
1162
|
|
|
1145
1163
|
|
|
1146
1164
|
def _intersects_if_not_none_or_empty(obj: Any, other: Any) -> bool:
|
sgis/maps/maps.py
CHANGED
|
@@ -32,6 +32,7 @@ from ..geopandas_tools.geometry_types import get_geom_type
|
|
|
32
32
|
from .explore import Explore
|
|
33
33
|
from .map import Map
|
|
34
34
|
from .thematicmap import ThematicMap
|
|
35
|
+
from .wms import WmsLoader
|
|
35
36
|
|
|
36
37
|
try:
|
|
37
38
|
from torchgeo.datasets.geo import RasterDataset
|
|
@@ -57,6 +58,9 @@ def _get_location_mask(kwargs: dict, gdfs) -> tuple[GeoDataFrame | None, dict]:
|
|
|
57
58
|
"akersveien": (10.7476367, 59.9222191),
|
|
58
59
|
"kongsvinger": (12.0035242, 60.1875279),
|
|
59
60
|
"stavanger": (5.6960601, 58.8946196),
|
|
61
|
+
"trondheim": (10.39677054, 63.42687816),
|
|
62
|
+
"trondhjem": (10.39677054, 63.42687816),
|
|
63
|
+
"bergen": (5.32574594, 60.39550309),
|
|
60
64
|
"volda": (6.0705987, 62.146643),
|
|
61
65
|
}
|
|
62
66
|
|
|
@@ -87,6 +91,7 @@ def explore(
|
|
|
87
91
|
size: int | None = None,
|
|
88
92
|
max_images: int = 10,
|
|
89
93
|
max_nodata_percentage: int = 100,
|
|
94
|
+
wms: WmsLoader | None = None,
|
|
90
95
|
**kwargs,
|
|
91
96
|
) -> Explore:
|
|
92
97
|
"""Interactive map of GeoDataFrames with layers that can be toggled on/off.
|
|
@@ -118,6 +123,7 @@ def explore(
|
|
|
118
123
|
map. Defaults to 10.
|
|
119
124
|
max_nodata_percentage: Maximum percentage nodata values (e.g. clouds) ro allow in
|
|
120
125
|
image arrays.
|
|
126
|
+
wms: A WmsLoader instance for loading image tiles as layers. E.g. NorgeIBilderWms.
|
|
121
127
|
**kwargs: Keyword arguments to pass to geopandas.GeoDataFrame.explore, for
|
|
122
128
|
instance 'cmap' to change the colors, 'scheme' to change how the data
|
|
123
129
|
is grouped. This defaults to 'fisherjenkssampled' for numeric data.
|
|
@@ -167,6 +173,7 @@ def explore(
|
|
|
167
173
|
max_zoom=max_zoom,
|
|
168
174
|
max_images=max_images,
|
|
169
175
|
max_nodata_percentage=max_nodata_percentage,
|
|
176
|
+
wms=wms,
|
|
170
177
|
**kwargs,
|
|
171
178
|
)
|
|
172
179
|
|
|
@@ -224,6 +231,7 @@ def explore(
|
|
|
224
231
|
max_zoom=max_zoom,
|
|
225
232
|
max_images=max_images,
|
|
226
233
|
max_nodata_percentage=max_nodata_percentage,
|
|
234
|
+
wms=wms,
|
|
227
235
|
**kwargs,
|
|
228
236
|
)
|
|
229
237
|
|
|
@@ -235,6 +243,7 @@ def explore(
|
|
|
235
243
|
smooth_factor=smooth_factor,
|
|
236
244
|
max_images=max_images,
|
|
237
245
|
max_nodata_percentage=max_nodata_percentage,
|
|
246
|
+
wms=wms,
|
|
238
247
|
**kwargs,
|
|
239
248
|
)
|
|
240
249
|
|
|
@@ -260,6 +269,7 @@ def samplemap(
|
|
|
260
269
|
browser: bool = False,
|
|
261
270
|
max_images: int = 10,
|
|
262
271
|
max_nodata_percentage: int = 100,
|
|
272
|
+
wms: WmsLoader | None = None,
|
|
263
273
|
**kwargs,
|
|
264
274
|
) -> Explore:
|
|
265
275
|
"""Shows an interactive map of a random area of GeoDataFrames.
|
|
@@ -295,6 +305,7 @@ def samplemap(
|
|
|
295
305
|
map. Defaults to 10.
|
|
296
306
|
max_nodata_percentage: Maximum percentage nodata values (e.g. clouds) ro allow in
|
|
297
307
|
image arrays.
|
|
308
|
+
wms: A WmsLoader instance for loading image tiles as layers. E.g. NorgeIBilderWms.
|
|
298
309
|
**kwargs: Keyword arguments to pass to geopandas.GeoDataFrame.explore, for
|
|
299
310
|
instance 'cmap' to change the colors, 'scheme' to change how the data
|
|
300
311
|
is grouped. This defaults to 'fisherjenkssampled' for numeric data.
|
|
@@ -378,6 +389,7 @@ def samplemap(
|
|
|
378
389
|
smooth_factor=smooth_factor,
|
|
379
390
|
max_images=max_images,
|
|
380
391
|
max_nodata_percentage=max_nodata_percentage,
|
|
392
|
+
wms=wms,
|
|
381
393
|
**kwargs,
|
|
382
394
|
)
|
|
383
395
|
|
|
@@ -392,6 +404,7 @@ def clipmap(
|
|
|
392
404
|
browser: bool = False,
|
|
393
405
|
max_images: int = 10,
|
|
394
406
|
max_nodata_percentage: int = 100,
|
|
407
|
+
wms: WmsLoader | None = None,
|
|
395
408
|
**kwargs,
|
|
396
409
|
) -> Explore | Map:
|
|
397
410
|
"""Shows an interactive map of a of GeoDataFrames clipped to the mask extent.
|
|
@@ -422,6 +435,7 @@ def clipmap(
|
|
|
422
435
|
map. Defaults to 10.
|
|
423
436
|
max_nodata_percentage: Maximum percentage nodata values (e.g. clouds) ro allow in
|
|
424
437
|
image arrays.
|
|
438
|
+
wms: A WmsLoader instance for loading image tiles as layers. E.g. NorgeIBilderWms.
|
|
425
439
|
**kwargs: Keyword arguments to pass to geopandas.GeoDataFrame.explore, for
|
|
426
440
|
instance 'cmap' to change the colors, 'scheme' to change how the data
|
|
427
441
|
is grouped. This defaults to 'fisherjenkssampled' for numeric data.
|
|
@@ -457,6 +471,7 @@ def clipmap(
|
|
|
457
471
|
smooth_factor=smooth_factor,
|
|
458
472
|
max_images=max_images,
|
|
459
473
|
max_nodata_percentage=max_nodata_percentage,
|
|
474
|
+
wms=wms,
|
|
460
475
|
**kwargs,
|
|
461
476
|
)
|
|
462
477
|
m.mask = mask
|