ssb-sgis 1.1.0__py3-none-any.whl → 1.1.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/maps/explore.py CHANGED
@@ -4,7 +4,6 @@ This module holds the Explore class, which is the basis for the explore, samplem
4
4
  clipmap functions from the 'maps' module.
5
5
  """
6
6
 
7
- import os
8
7
  import random
9
8
  import re
10
9
  import warnings
@@ -44,6 +43,7 @@ from ..geopandas_tools.general import clean_geoms
44
43
  from ..geopandas_tools.general import make_all_singlepart
45
44
  from ..geopandas_tools.geometry_types import get_geom_type
46
45
  from ..geopandas_tools.geometry_types import to_single_geom_type
46
+ from ..helpers import _get_file_system
47
47
  from .wms import WmsLoader
48
48
 
49
49
  try:
@@ -114,6 +114,20 @@ _MAP_KWARGS = [
114
114
  ]
115
115
 
116
116
 
117
+ class HtmlViewer:
118
+ """To be passed to IPython.display.display to show as map in Jupyter."""
119
+
120
+ def __init__(self, path: str, file_system=None) -> None:
121
+ """Takes a file path."""
122
+ self.file_system = _get_file_system(file_system, {})
123
+ self.path = path
124
+
125
+ def _repr_html_(self) -> str:
126
+ """Method to be used by IPython.display.display."""
127
+ with self.file_system.open(self.path, "r") as file:
128
+ return file.read()
129
+
130
+
117
131
  class MeasureControlFix(plugins.MeasureControl):
118
132
  """Monkey-patch to fix a bug in the lenght measurement control.
119
133
 
@@ -281,6 +295,7 @@ class Explore(Map):
281
295
  max_nodata_percentage: int = 100,
282
296
  display: bool = True,
283
297
  wms: WmsLoader | None = None,
298
+ file_system=None,
284
299
  **kwargs,
285
300
  ) -> None:
286
301
  """Initialiser.
@@ -311,6 +326,8 @@ class Explore(Map):
311
326
  image arrays.
312
327
  display: Whether to display the map interactively.
313
328
  wms: A WmsLoader instance for loading image tiles as layers. E.g. NorgeIBilderWms.
329
+ file_system: Any file system instance with an 'open' method. Used to write html file
330
+ to 'out_path'.
314
331
  **kwargs: Additional keyword arguments. Can also be geometry-like objects
315
332
  where the key is the label.
316
333
  """
@@ -329,6 +346,7 @@ class Explore(Map):
329
346
  self.display = display
330
347
  self.wms = [wms] if isinstance(wms, WmsLoader) else wms
331
348
  self.legend = None
349
+ self.file_system = _get_file_system(file_system, kwargs)
332
350
 
333
351
  self.browser = browser
334
352
  if not self.browser and "show_in_browser" in kwargs:
@@ -614,8 +632,9 @@ class Explore(Map):
614
632
 
615
633
  def save(self, path: str) -> None:
616
634
  """Save the map to local disk as an html document."""
617
- with open(path, "w") as f:
635
+ with self.file_system.open(path, "w") as f:
618
636
  f.write(self.map._repr_html_())
637
+ print(f"display(sg.HtmlViewer('{self.out_path}'))")
619
638
 
620
639
  def _explore(self, **kwargs) -> None:
621
640
  self.kwargs = self.kwargs | kwargs
@@ -629,10 +648,9 @@ class Explore(Map):
629
648
  self._create_continous_map()
630
649
 
631
650
  if self.out_path:
632
- with open(
633
- os.getcwd() + "/" + self.out_path.strip(".html") + ".html", "w"
634
- ) as f:
651
+ with self.file_system.open(self.out_path, "w") as f:
635
652
  f.write(self.map._repr_html_())
653
+ print(f"display(sg.HtmlViewer('{self.out_path}'))")
636
654
  elif self.browser:
637
655
  run_html_server(self.map._repr_html_())
638
656
  elif not self.display:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ssb-sgis
3
- Version: 1.1.0
3
+ Version: 1.1.2
4
4
  Summary: GIS functions used at Statistics Norway.
5
5
  Home-page: https://github.com/statisticsnorway/ssb-sgis
6
6
  License: MIT
@@ -1,13 +1,14 @@
1
- sgis/__init__.py,sha256=Bh-W4cB6-1uc-xRzUxqxECwwoennpdlikZI3gwXtZ7E,7389
1
+ sgis/__init__.py,sha256=kzqGuEIjkxATr3nVKWDE1SVkXp6NoLXoZNZzXd_w1dc,7419
2
+ sgis/conf.py,sha256=5GYeg00-qXtV_roskBaihZ2s5Ut3oF-cxjICo9UFJU0,2134
2
3
  sgis/debug_config.py,sha256=Tfr19kU46hSkkspsIJcrUWvlhaL4U3-f8xEPkujSCAQ,593
3
4
  sgis/exceptions.py,sha256=WNaEBPNNx0rmz-YDzlFX4vIE7ocJQruUTqS2RNAu2zU,660
4
5
  sgis/geopandas_tools/__init__.py,sha256=bo8lFMcltOz7TtWAi52_ekR2gd3mjfBfKeMDV5zuqFY,28
5
6
  sgis/geopandas_tools/bounds.py,sha256=MUtm3w6P_t7RfZ8WJz5iKqG2PyVzFMiAALf6AMLAewk,23798
6
7
  sgis/geopandas_tools/buffer_dissolve_explode.py,sha256=t9GJqRMDsHEU74RIlqeMr4QBgbTK0hYlXL4af1RKIks,19955
7
8
  sgis/geopandas_tools/centerlines.py,sha256=Q65Sx01SeAlulBEd9oaZkB2maBBNdLcJwAbTILg4SPU,11848
8
- sgis/geopandas_tools/cleaning.py,sha256=tkHH5wm0BF_1EXMsh3rM9DqWOwtr7JKkqCCi6uymSP4,60214
9
+ sgis/geopandas_tools/cleaning.py,sha256=_V3KrJBaL8hZk1Iv6HBfTMTe7GCgcRbWfelkWOxqaIg,24116
9
10
  sgis/geopandas_tools/conversion.py,sha256=o3QJZLfaqqpJNdWWNKfQn_dS77uJxxRxWZxhf18vPXs,25505
10
- sgis/geopandas_tools/duplicates.py,sha256=LG8-BG8LdA2zjWauuloslIZHvMGND6Fja0MtXIPZ1wo,14301
11
+ sgis/geopandas_tools/duplicates.py,sha256=qtcwMg310QytXBTV7XIJpPghZKz5Zyt7P59BHqc93gw,14919
11
12
  sgis/geopandas_tools/general.py,sha256=_XpQf792JqkvnMvEqtUMkPGVhjsct2SHSAyDYFdCyuQ,39885
12
13
  sgis/geopandas_tools/geocoding.py,sha256=n47aFQMm4yX1MsPnTM4dFjwegCA1ZmGUDj1uyu7OJV4,691
13
14
  sgis/geopandas_tools/geometry_types.py,sha256=ijQDbQaZPqPGjBl707H4yooNXpk21RXyatI7itnvqLk,7603
@@ -17,14 +18,15 @@ sgis/geopandas_tools/point_operations.py,sha256=JM4hvfIVxZaZdGNlGzcCurrKzkgC_b9h
17
18
  sgis/geopandas_tools/polygon_operations.py,sha256=FJ-dXCxLHRsmp0oXsmBOFRprFFwmhrxqOPZkW2WWWQM,50088
18
19
  sgis/geopandas_tools/polygons_as_rings.py,sha256=BX_GZS6F9I4NbEpiOlNBd7zywJjdfdJVi_MkeONBuiM,14941
19
20
  sgis/geopandas_tools/sfilter.py,sha256=SLcMYprQwnY5DNo0R7TGXk4m6u26H8o4PRn-RPhmeZY,9345
20
- sgis/helpers.py,sha256=3NqPfVBKlZcZTiMJrsTAlDv5tNKDHrJr_8NimutVzQg,8797
21
+ sgis/helpers.py,sha256=Ah4vFPQwnAFkZRALLBiR5iXwRMrx89kNTx5-5NTHsY8,9475
22
+ sgis/io/__init__.py,sha256=uyBr20YDqB2bQttrd5q1JuGOvX32A-MSvS7Wmw5f5qg,177
21
23
  sgis/io/_is_dapla.py,sha256=wmfkSe98IrLhUg3dtXZusV6OVC8VlY1kbc5EQDf3P-Q,358
22
- sgis/io/dapla_functions.py,sha256=o1TlMyKhuOpXx6I_Pi2XPAPUcN5XRYEzTcZMfmfe09c,18205
24
+ sgis/io/dapla_functions.py,sha256=jHE67ADF1Fu3WG1-4x696r6f4pSUG3f9JaJu_c2Aqjs,29360
23
25
  sgis/io/opener.py,sha256=HWO3G1NB6bpXKM94JadCD513vjat1o1TFjWGWzyVasg,898
24
26
  sgis/io/read_parquet.py,sha256=FvZYv1rLkUlrSaUY6QW6E1yntmntTeQuZ9ZRgCDO4IM,3776
25
27
  sgis/maps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
28
  sgis/maps/examine.py,sha256=Pb0dH8JazU5E2svfQrzHO1Bi-sjy5SeyY6zoeMO34jE,9369
27
- sgis/maps/explore.py,sha256=JX9ZTeHVsV1KsXP2YNVBa21Edvc6EksKdbb3V6W0tKs,47051
29
+ sgis/maps/explore.py,sha256=AxgaUNAKnGY_b7T5e3mLfysvF8fpJshHxsmEQih8oBw,47846
28
30
  sgis/maps/httpserver.py,sha256=7Od9JMCtntcIQKk_TchetojMHzFHT9sPw7GANahI97c,1982
29
31
  sgis/maps/legend.py,sha256=lVRVCkhPmJRjGK23obFJZAO3qp6du1LYnobkkN7DPkc,26279
30
32
  sgis/maps/map.py,sha256=smaf9i53EoRZWmZjn9UuqlhzUvVs1XKo2ItIpHxyuik,29592
@@ -56,7 +58,7 @@ sgis/raster/indices.py,sha256=-J1HYmnT240iozvgagvyis6K0_GHZHRuUrPOgyoeIrY,223
56
58
  sgis/raster/regex.py,sha256=kYhVpRYzoXutx1dSYmqMoselWXww7MMEsTPmLZwHjbM,3759
57
59
  sgis/raster/sentinel_config.py,sha256=nySDqn2R8M6W8jguoBeSAK_zzbAsqmaI59i32446FwY,1268
58
60
  sgis/raster/zonal.py,sha256=D4Gyptw-yOLTCO41peIuYbY-DANsJCG19xXDlf1QAz4,2299
59
- ssb_sgis-1.1.0.dist-info/LICENSE,sha256=np3IfD5m0ZUofn_kVzDZqliozuiO6wrktw3LRPjyEiI,1073
60
- ssb_sgis-1.1.0.dist-info/METADATA,sha256=eu1eJIwc822GIYWGPYj9tgJlM7NPfJ2pRX9YuRp9J8s,11740
61
- ssb_sgis-1.1.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
62
- ssb_sgis-1.1.0.dist-info/RECORD,,
61
+ ssb_sgis-1.1.2.dist-info/LICENSE,sha256=np3IfD5m0ZUofn_kVzDZqliozuiO6wrktw3LRPjyEiI,1073
62
+ ssb_sgis-1.1.2.dist-info/METADATA,sha256=SkKkxMGWK9n2CGvI0D4FQ4Hb4UKV9TAba38iTlDiQVI,11740
63
+ ssb_sgis-1.1.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
64
+ ssb_sgis-1.1.2.dist-info/RECORD,,