ssb-sgis 1.0.13__tar.gz → 1.0.15__tar.gz

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 (62) hide show
  1. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/PKG-INFO +1 -1
  2. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/pyproject.toml +1 -1
  3. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/__init__.py +1 -0
  4. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/maps/explore.py +19 -1
  5. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/maps/maps.py +15 -0
  6. ssb_sgis-1.0.15/src/sgis/maps/norge_i_bilder.json +11517 -0
  7. ssb_sgis-1.0.15/src/sgis/maps/wms.py +187 -0
  8. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/LICENSE +0 -0
  9. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/README.md +0 -0
  10. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/debug_config.py +0 -0
  11. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/exceptions.py +0 -0
  12. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/__init__.py +0 -0
  13. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/bounds.py +0 -0
  14. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/buffer_dissolve_explode.py +0 -0
  15. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/centerlines.py +0 -0
  16. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/cleaning.py +0 -0
  17. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/conversion.py +0 -0
  18. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/duplicates.py +0 -0
  19. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/general.py +0 -0
  20. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/geocoding.py +0 -0
  21. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/geometry_types.py +0 -0
  22. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/neighbors.py +0 -0
  23. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/overlay.py +0 -0
  24. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/point_operations.py +0 -0
  25. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/polygon_operations.py +0 -0
  26. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/polygons_as_rings.py +0 -0
  27. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/sfilter.py +0 -0
  28. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/helpers.py +0 -0
  29. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/io/_is_dapla.py +0 -0
  30. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/io/dapla_functions.py +0 -0
  31. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/io/opener.py +0 -0
  32. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/io/read_parquet.py +0 -0
  33. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/maps/__init__.py +0 -0
  34. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/maps/examine.py +0 -0
  35. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/maps/httpserver.py +0 -0
  36. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/maps/legend.py +0 -0
  37. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/maps/map.py +0 -0
  38. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/maps/thematicmap.py +0 -0
  39. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/maps/tilesources.py +0 -0
  40. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/__init__.py +0 -0
  41. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/_get_route.py +0 -0
  42. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/_od_cost_matrix.py +0 -0
  43. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/_points.py +0 -0
  44. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/_service_area.py +0 -0
  45. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/closing_network_holes.py +0 -0
  46. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/cutting_lines.py +0 -0
  47. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/directednetwork.py +0 -0
  48. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/finding_isolated_networks.py +0 -0
  49. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/network.py +0 -0
  50. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/networkanalysis.py +0 -0
  51. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/networkanalysisrules.py +0 -0
  52. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/nodes.py +0 -0
  53. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/traveling_salesman.py +0 -0
  54. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/parallel/parallel.py +0 -0
  55. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/py.typed +0 -0
  56. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/raster/__init__.py +0 -0
  57. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/raster/base.py +0 -0
  58. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/raster/image_collection.py +0 -0
  59. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/raster/indices.py +0 -0
  60. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/raster/regex.py +0 -0
  61. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/raster/sentinel_config.py +0 -0
  62. {ssb_sgis-1.0.13 → ssb_sgis-1.0.15}/src/sgis/raster/zonal.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ssb-sgis
3
- Version: 1.0.13
3
+ Version: 1.0.15
4
4
  Summary: GIS functions used at Statistics Norway.
5
5
  Home-page: https://github.com/statisticsnorway/ssb-sgis
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "ssb-sgis"
3
- version = "1.0.13"
3
+ version = "1.0.15"
4
4
  description = "GIS functions used at Statistics Norway."
5
5
  authors = ["Morten Letnes <morten.letnes@ssb.no>"]
6
6
  license = "MIT"
@@ -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
@@ -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, str):
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:
@@ -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