ssb-sgis 0.3.9__py3-none-any.whl → 0.3.11__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 +13 -4
- sgis/geopandas_tools/bounds.py +236 -37
- sgis/geopandas_tools/buffer_dissolve_explode.py +41 -9
- sgis/geopandas_tools/cleaning.py +521 -169
- sgis/geopandas_tools/conversion.py +2 -2
- sgis/geopandas_tools/duplicates.py +22 -18
- sgis/geopandas_tools/general.py +87 -9
- sgis/geopandas_tools/overlay.py +12 -4
- sgis/geopandas_tools/polygon_operations.py +83 -8
- sgis/geopandas_tools/sfilter.py +53 -53
- sgis/helpers.py +8 -0
- sgis/io/dapla_functions.py +9 -6
- sgis/maps/explore.py +76 -1
- sgis/maps/maps.py +11 -8
- {ssb_sgis-0.3.9.dist-info → ssb_sgis-0.3.11.dist-info}/METADATA +1 -4
- {ssb_sgis-0.3.9.dist-info → ssb_sgis-0.3.11.dist-info}/RECORD +18 -18
- {ssb_sgis-0.3.9.dist-info → ssb_sgis-0.3.11.dist-info}/LICENSE +0 -0
- {ssb_sgis-0.3.9.dist-info → ssb_sgis-0.3.11.dist-info}/WHEEL +0 -0
sgis/maps/explore.py
CHANGED
|
@@ -23,7 +23,7 @@ from pandas.api.types import is_datetime64_any_dtype
|
|
|
23
23
|
from shapely import Geometry
|
|
24
24
|
from shapely.geometry import LineString
|
|
25
25
|
|
|
26
|
-
from ..geopandas_tools.conversion import to_gdf
|
|
26
|
+
from ..geopandas_tools.conversion import from_4326, to_gdf
|
|
27
27
|
from ..geopandas_tools.general import clean_geoms, make_all_singlepart
|
|
28
28
|
from ..geopandas_tools.geometry_types import get_geom_type, to_single_geom_type
|
|
29
29
|
from .httpserver import run_html_server
|
|
@@ -103,6 +103,7 @@ def to_tile(tile: str | xyzservices.TileProvider, max_zoom: int) -> folium.TileL
|
|
|
103
103
|
"norge_i_bilder": kartverket.norge_i_bilder,
|
|
104
104
|
"dark": xyz.CartoDB.DarkMatter,
|
|
105
105
|
"voyager": xyz.CartoDB.Voyager,
|
|
106
|
+
"strava": xyz.Strava.All,
|
|
106
107
|
}
|
|
107
108
|
try:
|
|
108
109
|
name = tile["name"]
|
|
@@ -142,6 +143,7 @@ class Explore(Map):
|
|
|
142
143
|
def __init__(
|
|
143
144
|
self,
|
|
144
145
|
*gdfs,
|
|
146
|
+
mask=None,
|
|
145
147
|
column: str | None = None,
|
|
146
148
|
popup: bool = True,
|
|
147
149
|
max_zoom: int = 30,
|
|
@@ -152,6 +154,7 @@ class Explore(Map):
|
|
|
152
154
|
geocoder: bool = True,
|
|
153
155
|
save=None,
|
|
154
156
|
show: bool | Iterable[bool] | None = None,
|
|
157
|
+
text: str | None = None,
|
|
155
158
|
**kwargs,
|
|
156
159
|
):
|
|
157
160
|
self.popup = popup
|
|
@@ -161,6 +164,8 @@ class Explore(Map):
|
|
|
161
164
|
self.measure_control = measure_control
|
|
162
165
|
self.geocoder = geocoder
|
|
163
166
|
self.save = save
|
|
167
|
+
self.mask = mask
|
|
168
|
+
self.text = text
|
|
164
169
|
|
|
165
170
|
self.browser = browser
|
|
166
171
|
if not self.browser and "show_in_browser" in kwargs:
|
|
@@ -232,6 +237,11 @@ class Explore(Map):
|
|
|
232
237
|
if self._gdf.crs is None:
|
|
233
238
|
self.kwargs["crs"] = "Simple"
|
|
234
239
|
|
|
240
|
+
self.original_crs = self.gdf.crs
|
|
241
|
+
|
|
242
|
+
def __repr__(self):
|
|
243
|
+
return f"{self.__class__.__name__}()"
|
|
244
|
+
|
|
235
245
|
def explore(
|
|
236
246
|
self, column: str | None = None, center=None, size=None, **kwargs
|
|
237
247
|
) -> None:
|
|
@@ -243,6 +253,9 @@ class Explore(Map):
|
|
|
243
253
|
self._update_column()
|
|
244
254
|
kwargs.pop("column", None)
|
|
245
255
|
|
|
256
|
+
if self.mask is not None:
|
|
257
|
+
return self.clipmap(mask=self.mask, column=self._column, **kwargs)
|
|
258
|
+
|
|
246
259
|
if center is None:
|
|
247
260
|
self.to_show = self._gdfs
|
|
248
261
|
self._explore(**kwargs)
|
|
@@ -626,6 +639,12 @@ class Explore(Map):
|
|
|
626
639
|
if fit and "zoom_start" not in kwargs:
|
|
627
640
|
m.fit_bounds([[bounds[1], bounds[0]], [bounds[3], bounds[2]]])
|
|
628
641
|
|
|
642
|
+
if self.text:
|
|
643
|
+
style = bc.element.MacroElement()
|
|
644
|
+
style._template = bc.element.Template(get_textbox(self.text))
|
|
645
|
+
m.get_root().add_child(style)
|
|
646
|
+
# folium.LayerControl(collapsed=False).add_to(m)
|
|
647
|
+
|
|
629
648
|
return m
|
|
630
649
|
|
|
631
650
|
def _make_geojson(
|
|
@@ -907,3 +926,59 @@ def _categorical_legend(m, title, categories, colors):
|
|
|
907
926
|
# Add Body
|
|
908
927
|
body = bc.element.Element(body, "legend")
|
|
909
928
|
m.get_root().html.add_child(body)
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
def get_textbox(text: str) -> str:
|
|
932
|
+
return f"""
|
|
933
|
+
{{% macro html(this, kwargs) %}}
|
|
934
|
+
<!doctype html>
|
|
935
|
+
<html lang="en">
|
|
936
|
+
<head>
|
|
937
|
+
<meta charset="utf-8">
|
|
938
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
939
|
+
<title>Textbox Project</title>
|
|
940
|
+
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
|
|
941
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css" integrity="sha512-MV7K8+y+gLIBoVD59lQIYicR65iaqukzvf/nwasF0nqhPay5w/9lJmVM2hMDcnK1OnMGCdVK+iQrJ7lzPJQd1w==" crossorigin="anonymous" referrerpolicy="no-referrer"/>
|
|
942
|
+
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
|
|
943
|
+
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
|
|
944
|
+
|
|
945
|
+
<script>
|
|
946
|
+
$( function() {{
|
|
947
|
+
$( "#textbox" ).draggable({{
|
|
948
|
+
start: function (event, ui) {{
|
|
949
|
+
$(this).css({{
|
|
950
|
+
right: "auto",
|
|
951
|
+
top: "auto",
|
|
952
|
+
bottom: "auto"
|
|
953
|
+
}});
|
|
954
|
+
}}
|
|
955
|
+
}});
|
|
956
|
+
}});
|
|
957
|
+
</script>
|
|
958
|
+
</head>
|
|
959
|
+
|
|
960
|
+
<body>
|
|
961
|
+
<div id="textbox" class="textbox">
|
|
962
|
+
<div class="textbox-content">
|
|
963
|
+
<p>{text}</p>
|
|
964
|
+
</div>
|
|
965
|
+
</div>
|
|
966
|
+
|
|
967
|
+
</body>
|
|
968
|
+
</html>
|
|
969
|
+
|
|
970
|
+
<style type='text/css'>
|
|
971
|
+
.textbox {{
|
|
972
|
+
position: absolute;
|
|
973
|
+
z-index:9999;
|
|
974
|
+
border-radius:4px;
|
|
975
|
+
background: white;
|
|
976
|
+
padding: 1px;
|
|
977
|
+
font-size:11px;
|
|
978
|
+
left: 20px;
|
|
979
|
+
top: 50%;
|
|
980
|
+
color: black;
|
|
981
|
+
}}
|
|
982
|
+
</style>
|
|
983
|
+
{{% endmacro %}}
|
|
984
|
+
"""
|
sgis/maps/maps.py
CHANGED
|
@@ -16,10 +16,9 @@ from geopandas import GeoDataFrame, GeoSeries
|
|
|
16
16
|
from shapely import Geometry
|
|
17
17
|
|
|
18
18
|
from ..geopandas_tools.conversion import to_gdf as to_gdf_func
|
|
19
|
-
from ..geopandas_tools.general import
|
|
19
|
+
from ..geopandas_tools.general import clean_geoms, get_common_crs, is_wkt
|
|
20
20
|
from ..geopandas_tools.geocoding import address_to_gdf
|
|
21
21
|
from ..geopandas_tools.geometry_types import get_geom_type
|
|
22
|
-
from ..helpers import make_namedict
|
|
23
22
|
from .explore import Explore
|
|
24
23
|
from .map import Map
|
|
25
24
|
from .thematicmap import ThematicMap
|
|
@@ -27,12 +26,16 @@ from .thematicmap import ThematicMap
|
|
|
27
26
|
|
|
28
27
|
def _get_location_mask(kwargs: dict, gdfs) -> tuple[GeoDataFrame | None, dict]:
|
|
29
28
|
try:
|
|
30
|
-
crs = gdfs
|
|
29
|
+
crs = get_common_crs(gdfs)
|
|
31
30
|
except IndexError:
|
|
32
|
-
|
|
31
|
+
try:
|
|
32
|
+
crs = [x for x in kwargs.values() if hasattr(x, "crs")][0].crs
|
|
33
|
+
except IndexError:
|
|
34
|
+
crs = None
|
|
33
35
|
|
|
34
36
|
masks = {
|
|
35
37
|
"bygdoy": (10.6976899, 59.9081695),
|
|
38
|
+
"akersveien": (10.7476367, 59.9222191),
|
|
36
39
|
"kongsvinger": (12.0035242, 60.1875279),
|
|
37
40
|
"stavanger": (5.6960601, 58.8946196),
|
|
38
41
|
"volda": (6.0705987, 62.146643),
|
|
@@ -60,7 +63,7 @@ def explore(
|
|
|
60
63
|
column: str | None = None,
|
|
61
64
|
center: Any | None = None,
|
|
62
65
|
labels: tuple[str] | None = None,
|
|
63
|
-
max_zoom: int =
|
|
66
|
+
max_zoom: int = 40,
|
|
64
67
|
browser: bool = False,
|
|
65
68
|
smooth_factor: int | float = 1.5,
|
|
66
69
|
size: int | None = None,
|
|
@@ -182,7 +185,7 @@ def explore(
|
|
|
182
185
|
if not kwargs.pop("explore", True):
|
|
183
186
|
return qtm(m._gdf, column=m.column, cmap=m._cmap, k=m.k)
|
|
184
187
|
|
|
185
|
-
|
|
188
|
+
m.explore()
|
|
186
189
|
|
|
187
190
|
|
|
188
191
|
def samplemap(
|
|
@@ -191,7 +194,7 @@ def samplemap(
|
|
|
191
194
|
size: int = 1000,
|
|
192
195
|
sample_from_first: bool = True,
|
|
193
196
|
labels: tuple[str] | None = None,
|
|
194
|
-
max_zoom: int =
|
|
197
|
+
max_zoom: int = 40,
|
|
195
198
|
smooth_factor: int = 1.5,
|
|
196
199
|
explore: bool = True,
|
|
197
200
|
browser: bool = False,
|
|
@@ -320,7 +323,7 @@ def clipmap(
|
|
|
320
323
|
mask: GeoDataFrame | GeoSeries | Geometry = None,
|
|
321
324
|
labels: tuple[str] | None = None,
|
|
322
325
|
explore: bool = True,
|
|
323
|
-
max_zoom: int =
|
|
326
|
+
max_zoom: int = 40,
|
|
324
327
|
smooth_factor: int | float = 1.5,
|
|
325
328
|
browser: bool = False,
|
|
326
329
|
**kwargs,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ssb-sgis
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.11
|
|
4
4
|
Summary: GIS functions used at Statistics Norway.
|
|
5
5
|
Home-page: https://github.com/statisticsnorway/ssb-sgis
|
|
6
6
|
License: MIT
|
|
@@ -24,18 +24,15 @@ Requires-Dist: jenkspy (>=0.3.2)
|
|
|
24
24
|
Requires-Dist: mapclassify (>=2.5.0)
|
|
25
25
|
Requires-Dist: matplotlib (>=3.7.0)
|
|
26
26
|
Requires-Dist: networkx (>=3.0)
|
|
27
|
-
Requires-Dist: numba (>=0.57.1,<0.58.0)
|
|
28
27
|
Requires-Dist: numpy (>=1.24.2)
|
|
29
28
|
Requires-Dist: pandas (>=1.5.3)
|
|
30
29
|
Requires-Dist: pip (==23.2.1)
|
|
31
30
|
Requires-Dist: pyarrow (>=11.0.0)
|
|
32
31
|
Requires-Dist: rasterio (>=1.3.8,<2.0.0)
|
|
33
32
|
Requires-Dist: requests (>=2.28.2)
|
|
34
|
-
Requires-Dist: rioxarray (>=0.14.1,<0.15.0)
|
|
35
33
|
Requires-Dist: rtree (>=1.0.1,<2.0.0)
|
|
36
34
|
Requires-Dist: scikit-learn (>=1.2.1)
|
|
37
35
|
Requires-Dist: shapely (>=2.0.1)
|
|
38
|
-
Requires-Dist: xarray (==2023.8.0)
|
|
39
36
|
Requires-Dist: xyzservices (>=2023.2.0)
|
|
40
37
|
Project-URL: Changelog, https://github.com/statisticsnorway/ssb-sgis/releases
|
|
41
38
|
Project-URL: Repository, https://github.com/statisticsnorway/ssb-sgis
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
sgis/__init__.py,sha256=
|
|
1
|
+
sgis/__init__.py,sha256=cYkxK-L-T8KPXZEcRTt3R9JAmfIAo9gZzb6iJHMabfA,3742
|
|
2
2
|
sgis/exceptions.py,sha256=ztMp4sB9xxPvwj2IEsO5kOaB4FmHuU_7-M2pZ7qaxTs,576
|
|
3
3
|
sgis/geopandas_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
sgis/geopandas_tools/bounds.py,sha256=
|
|
5
|
-
sgis/geopandas_tools/buffer_dissolve_explode.py,sha256=
|
|
4
|
+
sgis/geopandas_tools/bounds.py,sha256=5OdlImhXRGf24EZWnwaDR38fW2vjG62lUp_HgY-zc8U,24493
|
|
5
|
+
sgis/geopandas_tools/buffer_dissolve_explode.py,sha256=S7sCsbWsniTIrQtRYaYPuQrUWkjta1iprekXBjpimTQ,13358
|
|
6
6
|
sgis/geopandas_tools/centerlines.py,sha256=96jZpORHm-As4MoT8ImHPCoq2UDyBhKKw98a84Qes-A,14142
|
|
7
|
-
sgis/geopandas_tools/cleaning.py,sha256=
|
|
8
|
-
sgis/geopandas_tools/conversion.py,sha256=
|
|
9
|
-
sgis/geopandas_tools/duplicates.py,sha256=
|
|
10
|
-
sgis/geopandas_tools/general.py,sha256=
|
|
7
|
+
sgis/geopandas_tools/cleaning.py,sha256=MDSipABrxnCpB9YqWb-8j75f1bHzo4oXai4XJoNJPuk,22545
|
|
8
|
+
sgis/geopandas_tools/conversion.py,sha256=HvBvI6jLZ_TM0MSPJxmQJLLRoB5JX0EYLByNwfn0xCU,17239
|
|
9
|
+
sgis/geopandas_tools/duplicates.py,sha256=PYN9ZriFA-Lv6kyP9_GJKhcDMJwjdNdagIxuwxn5NC0,10438
|
|
10
|
+
sgis/geopandas_tools/general.py,sha256=AMDgCclUZGrs6Yr-c8YwjNPAgLiI3mL49ANwNSPOqX0,21347
|
|
11
11
|
sgis/geopandas_tools/geocoding.py,sha256=n47aFQMm4yX1MsPnTM4dFjwegCA1ZmGUDj1uyu7OJV4,691
|
|
12
12
|
sgis/geopandas_tools/geometry_types.py,sha256=9kv-CZFDp98QJykhkY1ZTT7gaH3s1-Q3FcozEFk4mvk,7147
|
|
13
13
|
sgis/geopandas_tools/neighbors.py,sha256=7jtO1ZWv71Gj0sI5OdbrfqhVqAHiHkkzxvBUZEn8M80,15047
|
|
14
|
-
sgis/geopandas_tools/overlay.py,sha256=
|
|
14
|
+
sgis/geopandas_tools/overlay.py,sha256=XZlV5RQSQhZ2DSpFflpVNFGXAjPkl4ZD_DNKdFFgRT4,14930
|
|
15
15
|
sgis/geopandas_tools/point_operations.py,sha256=Cpa02sf_W8nI6FvzJGO9jNM_ZOwIz8nDhKxNdQTqom4,6897
|
|
16
|
-
sgis/geopandas_tools/polygon_operations.py,sha256=
|
|
16
|
+
sgis/geopandas_tools/polygon_operations.py,sha256=iKFug2KVUC5uDp7Uv6EgeMbs-3yQMTMw5uOcdydmMi0,37858
|
|
17
17
|
sgis/geopandas_tools/polygons_as_rings.py,sha256=4NzdEuGD9BXKuXxcDEMt-qIoxmdq-nuwKqfjxdW3fJA,10276
|
|
18
|
-
sgis/geopandas_tools/sfilter.py,sha256
|
|
19
|
-
sgis/helpers.py,sha256=
|
|
18
|
+
sgis/geopandas_tools/sfilter.py,sha256=-ZoBXLTu76oMBAGFtkYOw4zxqsaX7ptJmrmVInDO2f0,8513
|
|
19
|
+
sgis/helpers.py,sha256=nDx1XRttZ563r2JAdWHuc7s2LZcmD7wxyFaUUk3-S3k,6190
|
|
20
20
|
sgis/io/_is_dapla.py,sha256=TZhVjrSfNmpNSRbt2C7L8OHXWnlmJ2euNX8IUY7xAjI,459
|
|
21
|
-
sgis/io/dapla_functions.py,sha256=
|
|
21
|
+
sgis/io/dapla_functions.py,sha256=x5mdXk3Y1AuqFaa7hKCLwwzDqTLHwA4R0P7ZUPZ-L3Q,7833
|
|
22
22
|
sgis/io/opener.py,sha256=Y5CzWFCJz_XweBTEHVysLOKhSEEXdrPsBk_7a63XmBg,538
|
|
23
23
|
sgis/io/read_parquet.py,sha256=GSW2NDy4-XosbamPEzB1xhWxFAPHuGEJZglfQ-V6DzY,3774
|
|
24
24
|
sgis/io/write_municipality_data.py,sha256=-EDUP6TcQCVEUT8XVwYVcqhYkzoltu9PpbjTTf8-afE,6457
|
|
25
25
|
sgis/maps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
26
|
sgis/maps/examine.py,sha256=UwGOuVnmO0nmnQm-7TSJQQs1AT1YW7RVA7w-kh56O7c,8073
|
|
27
|
-
sgis/maps/explore.py,sha256=
|
|
27
|
+
sgis/maps/explore.py,sha256=_fxC-bbYm0BFedeUiYWgT1RSDedNG08N6jjP-ecBIUU,29945
|
|
28
28
|
sgis/maps/httpserver.py,sha256=z9D66SizO9GIZKaSLIqpFWnwOZZh-kiuVPjFt3WZr8o,1902
|
|
29
29
|
sgis/maps/legend.py,sha256=buHo_UwzPYHIs7kS6H_xETekIR8m9R4PACXfTTMYQWE,20680
|
|
30
30
|
sgis/maps/map.py,sha256=Ba0xp_DJhT9QYTIfwsMphEyrd2oL_ReDEAt-s6tcfm0,22806
|
|
31
|
-
sgis/maps/maps.py,sha256=
|
|
31
|
+
sgis/maps/maps.py,sha256=ZTUwA7BHa8HBoGctZPNJjYidvS2Dx1ZR0XHeLRS9Uxs,18272
|
|
32
32
|
sgis/maps/thematicmap.py,sha256=6aVPciftW1YjxjRVQDipxayl3aI3tHpYiZ3HfpnSavc,14132
|
|
33
33
|
sgis/maps/tilesources.py,sha256=gGqNJ4d0PkIP72lZe2c5OMJsxJHz2DVsczw7QSjn96M,2733
|
|
34
34
|
sgis/networkanalysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -53,7 +53,7 @@ sgis/raster/elevationraster.py,sha256=yrE6dg0NgJp0KmrJqdygF74tKbnnwgLQ4rfwBELCYS
|
|
|
53
53
|
sgis/raster/raster.py,sha256=ZwtHpG86xwy83tz3Xhi72ZGuAX0_hIo6FAL_8j4VvYo,40862
|
|
54
54
|
sgis/raster/sentinel.py,sha256=0x1HwebRRTCExmsMAXwnct23eMXDBj_KHz8CoP0NOxI,1025
|
|
55
55
|
sgis/raster/zonal.py,sha256=P2bJ8Uvnrc4U1JbyBsKEhjGNaU4FOvRNmxOOF9EzM34,3249
|
|
56
|
-
ssb_sgis-0.3.
|
|
57
|
-
ssb_sgis-0.3.
|
|
58
|
-
ssb_sgis-0.3.
|
|
59
|
-
ssb_sgis-0.3.
|
|
56
|
+
ssb_sgis-0.3.11.dist-info/LICENSE,sha256=lL2h0dNKGTKAE0CjTy62SDbRennVD1xPgM5LzGqhKeo,1074
|
|
57
|
+
ssb_sgis-0.3.11.dist-info/METADATA,sha256=Fkw9AzLfURfstYd9UbyX8V2EbK3Nv4XonzJZefEixK8,9045
|
|
58
|
+
ssb_sgis-0.3.11.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
59
|
+
ssb_sgis-0.3.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|