ssb-sgis 1.0.14__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.14 → ssb_sgis-1.0.15}/PKG-INFO +1 -1
  2. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/pyproject.toml +1 -1
  3. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/__init__.py +1 -1
  4. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/maps/explore.py +11 -15
  5. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/maps/maps.py +12 -18
  6. ssb_sgis-1.0.14/src/sgis/maps/norge_i_bilder_wms.py → ssb_sgis-1.0.15/src/sgis/maps/wms.py +23 -1
  7. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/LICENSE +0 -0
  8. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/README.md +0 -0
  9. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/debug_config.py +0 -0
  10. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/exceptions.py +0 -0
  11. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/__init__.py +0 -0
  12. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/bounds.py +0 -0
  13. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/buffer_dissolve_explode.py +0 -0
  14. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/centerlines.py +0 -0
  15. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/cleaning.py +0 -0
  16. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/conversion.py +0 -0
  17. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/duplicates.py +0 -0
  18. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/general.py +0 -0
  19. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/geocoding.py +0 -0
  20. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/geometry_types.py +0 -0
  21. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/neighbors.py +0 -0
  22. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/overlay.py +0 -0
  23. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/point_operations.py +0 -0
  24. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/polygon_operations.py +0 -0
  25. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/polygons_as_rings.py +0 -0
  26. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/geopandas_tools/sfilter.py +0 -0
  27. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/helpers.py +0 -0
  28. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/io/_is_dapla.py +0 -0
  29. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/io/dapla_functions.py +0 -0
  30. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/io/opener.py +0 -0
  31. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/io/read_parquet.py +0 -0
  32. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/maps/__init__.py +0 -0
  33. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/maps/examine.py +0 -0
  34. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/maps/httpserver.py +0 -0
  35. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/maps/legend.py +0 -0
  36. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/maps/map.py +0 -0
  37. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/maps/norge_i_bilder.json +0 -0
  38. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/maps/thematicmap.py +0 -0
  39. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/maps/tilesources.py +0 -0
  40. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/__init__.py +0 -0
  41. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/_get_route.py +0 -0
  42. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/_od_cost_matrix.py +0 -0
  43. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/_points.py +0 -0
  44. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/_service_area.py +0 -0
  45. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/closing_network_holes.py +0 -0
  46. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/cutting_lines.py +0 -0
  47. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/directednetwork.py +0 -0
  48. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/finding_isolated_networks.py +0 -0
  49. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/network.py +0 -0
  50. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/networkanalysis.py +0 -0
  51. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/networkanalysisrules.py +0 -0
  52. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/nodes.py +0 -0
  53. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/networkanalysis/traveling_salesman.py +0 -0
  54. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/parallel/parallel.py +0 -0
  55. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/py.typed +0 -0
  56. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/raster/__init__.py +0 -0
  57. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/raster/base.py +0 -0
  58. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/raster/image_collection.py +0 -0
  59. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/raster/indices.py +0 -0
  60. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/raster/regex.py +0 -0
  61. {ssb_sgis-1.0.14 → ssb_sgis-1.0.15}/src/sgis/raster/sentinel_config.py +0 -0
  62. {ssb_sgis-1.0.14 → 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.14
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.14"
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"
@@ -96,10 +96,10 @@ from .maps.maps import explore
96
96
  from .maps.maps import explore_locals
97
97
  from .maps.maps import qtm
98
98
  from .maps.maps import samplemap
99
- from .maps.norge_i_bilder_wms import NorgeIBilderWms
100
99
  from .maps.thematicmap import ThematicMap
101
100
  from .maps.tilesources import kartverket as kartverket_tiles
102
101
  from .maps.tilesources import xyz as xyztiles
102
+ from .maps.wms import NorgeIBilderWms
103
103
  from .networkanalysis.closing_network_holes import close_network_holes
104
104
  from .networkanalysis.closing_network_holes import close_network_holes_to_deadends
105
105
  from .networkanalysis.closing_network_holes import get_k_nearest_points_for_deadends
@@ -44,7 +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 .norge_i_bilder_wms import NorgeIBilderWms
47
+ from .wms import WmsLoader
48
48
 
49
49
  try:
50
50
  from ..raster.image_collection import Band
@@ -280,7 +280,7 @@ class Explore(Map):
280
280
  max_images: int = 10,
281
281
  max_nodata_percentage: int = 100,
282
282
  display: bool = True,
283
- norge_i_bilder: bool = False,
283
+ wms: WmsLoader | None = None,
284
284
  **kwargs,
285
285
  ) -> None:
286
286
  """Initialiser.
@@ -310,9 +310,7 @@ class Explore(Map):
310
310
  max_nodata_percentage: Maximum percentage nodata values (e.g. clouds) ro allow in
311
311
  image arrays.
312
312
  display: Whether to display the map interactively.
313
- norge_i_bilder: If True, all Norge i bilder images in bounds will be loaded
314
- into the map. Can optionally be set to an instance of NorgeIBilderWms to filter
315
- years and names.
313
+ wms: A WmsLoader instance for loading image tiles as layers. E.g. NorgeIBilderWms.
316
314
  **kwargs: Additional keyword arguments. Can also be geometry-like objects
317
315
  where the key is the label.
318
316
  """
@@ -329,7 +327,7 @@ class Explore(Map):
329
327
  self.max_images = max_images
330
328
  self.max_nodata_percentage = max_nodata_percentage
331
329
  self.display = display
332
- self.norge_i_bilder = norge_i_bilder
330
+ self.wms = [wms] if isinstance(wms, WmsLoader) else wms
333
331
  self.legend = None
334
332
 
335
333
  self.browser = browser
@@ -768,13 +766,11 @@ class Explore(Map):
768
766
  for tile in tiles:
769
767
  to_tile(tile, max_zoom=self.max_zoom).add_to(mapobj)
770
768
 
771
- def _add_norge_i_bilder(self, map_: folium.Map, bbox: Any) -> None:
772
- if not isinstance(self.norge_i_bilder, NorgeIBilderWms):
773
- self.norge_i_bilder = NorgeIBilderWms()
774
-
775
- tiles = self.norge_i_bilder.get_tiles(bbox, max_zoom=self.max_zoom)
776
- for tile in tiles.values():
777
- map_.add_child(tile)
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)
778
774
 
779
775
  def _create_continous_map(self):
780
776
  self._prepare_continous_map()
@@ -982,8 +978,8 @@ class Explore(Map):
982
978
  m.get_root().add_child(style)
983
979
  # folium.LayerControl(collapsed=False).add_to(m)
984
980
 
985
- if self.norge_i_bilder:
986
- self._add_norge_i_bilder(m, bounds)
981
+ if self.wms:
982
+ self._add_wms(m, bounds)
987
983
 
988
984
  return m
989
985
 
@@ -31,8 +31,8 @@ from ..geopandas_tools.geocoding import address_to_gdf
31
31
  from ..geopandas_tools.geometry_types import get_geom_type
32
32
  from .explore import Explore
33
33
  from .map import Map
34
- from .norge_i_bilder_wms import NorgeIBilderWms
35
34
  from .thematicmap import ThematicMap
35
+ from .wms import WmsLoader
36
36
 
37
37
  try:
38
38
  from torchgeo.datasets.geo import RasterDataset
@@ -91,7 +91,7 @@ def explore(
91
91
  size: int | None = None,
92
92
  max_images: int = 10,
93
93
  max_nodata_percentage: int = 100,
94
- norge_i_bilder: bool | NorgeIBilderWms = False,
94
+ wms: WmsLoader | None = None,
95
95
  **kwargs,
96
96
  ) -> Explore:
97
97
  """Interactive map of GeoDataFrames with layers that can be toggled on/off.
@@ -123,9 +123,7 @@ def explore(
123
123
  map. Defaults to 10.
124
124
  max_nodata_percentage: Maximum percentage nodata values (e.g. clouds) ro allow in
125
125
  image arrays.
126
- norge_i_bilder: If True, all Norge i bilder images in bounds will be loaded
127
- into the map. Can optionally be set to an instance of NorgeIBilderWms to filter
128
- years and names.
126
+ wms: A WmsLoader instance for loading image tiles as layers. E.g. NorgeIBilderWms.
129
127
  **kwargs: Keyword arguments to pass to geopandas.GeoDataFrame.explore, for
130
128
  instance 'cmap' to change the colors, 'scheme' to change how the data
131
129
  is grouped. This defaults to 'fisherjenkssampled' for numeric data.
@@ -175,7 +173,7 @@ def explore(
175
173
  max_zoom=max_zoom,
176
174
  max_images=max_images,
177
175
  max_nodata_percentage=max_nodata_percentage,
178
- norge_i_bilder=norge_i_bilder,
176
+ wms=wms,
179
177
  **kwargs,
180
178
  )
181
179
 
@@ -233,7 +231,7 @@ def explore(
233
231
  max_zoom=max_zoom,
234
232
  max_images=max_images,
235
233
  max_nodata_percentage=max_nodata_percentage,
236
- norge_i_bilder=norge_i_bilder,
234
+ wms=wms,
237
235
  **kwargs,
238
236
  )
239
237
 
@@ -245,7 +243,7 @@ def explore(
245
243
  smooth_factor=smooth_factor,
246
244
  max_images=max_images,
247
245
  max_nodata_percentage=max_nodata_percentage,
248
- norge_i_bilder=norge_i_bilder,
246
+ wms=wms,
249
247
  **kwargs,
250
248
  )
251
249
 
@@ -271,7 +269,7 @@ def samplemap(
271
269
  browser: bool = False,
272
270
  max_images: int = 10,
273
271
  max_nodata_percentage: int = 100,
274
- norge_i_bilder: bool | NorgeIBilderWms = False,
272
+ wms: WmsLoader | None = None,
275
273
  **kwargs,
276
274
  ) -> Explore:
277
275
  """Shows an interactive map of a random area of GeoDataFrames.
@@ -307,9 +305,7 @@ def samplemap(
307
305
  map. Defaults to 10.
308
306
  max_nodata_percentage: Maximum percentage nodata values (e.g. clouds) ro allow in
309
307
  image arrays.
310
- norge_i_bilder: If True, all Norge i bilder images in bounds will be loaded
311
- into the map. Can optionally be set to an instance of NorgeIBilderWms to filter
312
- years and names.
308
+ wms: A WmsLoader instance for loading image tiles as layers. E.g. NorgeIBilderWms.
313
309
  **kwargs: Keyword arguments to pass to geopandas.GeoDataFrame.explore, for
314
310
  instance 'cmap' to change the colors, 'scheme' to change how the data
315
311
  is grouped. This defaults to 'fisherjenkssampled' for numeric data.
@@ -393,7 +389,7 @@ def samplemap(
393
389
  smooth_factor=smooth_factor,
394
390
  max_images=max_images,
395
391
  max_nodata_percentage=max_nodata_percentage,
396
- norge_i_bilder=norge_i_bilder,
392
+ wms=wms,
397
393
  **kwargs,
398
394
  )
399
395
 
@@ -408,7 +404,7 @@ def clipmap(
408
404
  browser: bool = False,
409
405
  max_images: int = 10,
410
406
  max_nodata_percentage: int = 100,
411
- norge_i_bilder: bool | NorgeIBilderWms = False,
407
+ wms: WmsLoader | None = None,
412
408
  **kwargs,
413
409
  ) -> Explore | Map:
414
410
  """Shows an interactive map of a of GeoDataFrames clipped to the mask extent.
@@ -439,9 +435,7 @@ def clipmap(
439
435
  map. Defaults to 10.
440
436
  max_nodata_percentage: Maximum percentage nodata values (e.g. clouds) ro allow in
441
437
  image arrays.
442
- norge_i_bilder: If True, all Norge i bilder images in bounds will be loaded
443
- into the map. Can optionally be set to an instance of NorgeIBilderWms to filter
444
- years and names.
438
+ wms: A WmsLoader instance for loading image tiles as layers. E.g. NorgeIBilderWms.
445
439
  **kwargs: Keyword arguments to pass to geopandas.GeoDataFrame.explore, for
446
440
  instance 'cmap' to change the colors, 'scheme' to change how the data
447
441
  is grouped. This defaults to 'fisherjenkssampled' for numeric data.
@@ -477,7 +471,7 @@ def clipmap(
477
471
  smooth_factor=smooth_factor,
478
472
  max_images=max_images,
479
473
  max_nodata_percentage=max_nodata_percentage,
480
- norge_i_bilder=norge_i_bilder,
474
+ wms=wms,
481
475
  **kwargs,
482
476
  )
483
477
  m.mask = mask
@@ -1,3 +1,4 @@
1
+ import abc
1
2
  import datetime
2
3
  import json
3
4
  import re
@@ -24,7 +25,28 @@ DEFAULT_YEARS: tuple[str] = tuple(
24
25
 
25
26
 
26
27
  @dataclass
27
- class NorgeIBilderWms:
28
+ class WmsLoader(abc.ABC):
29
+ """Abstract base class for wms loaders.
30
+
31
+ Child classes must implement the method 'get_tiles',
32
+ which should return a list of folium.WmsTileLayer.
33
+ """
34
+
35
+ @abc.abstractmethod
36
+ def get_tiles(self, bbox: Any, max_zoom: int = 40) -> list[folium.WmsTileLayer]:
37
+ """Get all tiles intersecting with a bbox."""
38
+
39
+ @abc.abstractmethod
40
+ def load_tiles(self) -> None:
41
+ """Load all tiles into self.tiles.
42
+
43
+ Not needed in sgis.explore.
44
+ """
45
+ pass
46
+
47
+
48
+ @dataclass
49
+ class NorgeIBilderWms(WmsLoader):
28
50
  """Loads Norge i bilder tiles as folium.WmsTiles."""
29
51
 
30
52
  years: Iterable[int | str] = DEFAULT_YEARS
File without changes
File without changes
File without changes
File without changes