ssb-sgis 1.2.6__tar.gz → 1.2.7__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.
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/PKG-INFO +1 -1
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/pyproject.toml +1 -1
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/geocoding.py +4 -4
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/sfilter.py +8 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/maps/explore.py +6 -2
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/maps/map.py +3 -2
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/maps/maps.py +9 -4
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/networkanalysis/_points.py +3 -5
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/raster/base.py +3 -5
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/raster/image_collection.py +1 -4
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/LICENSE +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/README.md +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/__init__.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/conf.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/debug_config.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/exceptions.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/__init__.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/bounds.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/buffer_dissolve_explode.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/centerlines.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/cleaning.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/conversion.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/duplicates.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/general.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/geometry_types.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/neighbors.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/overlay.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/point_operations.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/polygon_operations.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/polygons_as_rings.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/runners.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/geopandas_tools/utils.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/helpers.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/io/__init__.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/io/_is_dapla.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/io/dapla_functions.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/io/opener.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/io/read_parquet.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/maps/__init__.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/maps/examine.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/maps/httpserver.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/maps/legend.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/maps/norge_i_bilder.json +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/maps/thematicmap.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/maps/tilesources.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/maps/wms.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/networkanalysis/__init__.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/networkanalysis/_get_route.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/networkanalysis/_od_cost_matrix.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/networkanalysis/_service_area.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/networkanalysis/closing_network_holes.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/networkanalysis/cutting_lines.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/networkanalysis/directednetwork.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/networkanalysis/finding_isolated_networks.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/networkanalysis/network.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/networkanalysis/networkanalysis.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/networkanalysis/networkanalysisrules.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/networkanalysis/nodes.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/networkanalysis/traveling_salesman.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/parallel/__init__.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/parallel/parallel.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/py.typed +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/raster/__init__.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/raster/indices.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/raster/regex.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/raster/sentinel_config.py +0 -0
- {ssb_sgis-1.2.6 → ssb_sgis-1.2.7}/src/sgis/raster/zonal.py +0 -0
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
try:
|
|
2
|
-
import geocoder
|
|
3
|
-
except ImportError:
|
|
4
|
-
pass
|
|
5
1
|
from geopandas import GeoDataFrame
|
|
6
2
|
|
|
7
3
|
from .conversion import to_gdf
|
|
@@ -9,6 +5,8 @@ from .conversion import to_gdf
|
|
|
9
5
|
|
|
10
6
|
def address_to_gdf(address: str, crs=4326) -> GeoDataFrame:
|
|
11
7
|
"""Takes an address and returns a point GeoDataFrame."""
|
|
8
|
+
import geocoder
|
|
9
|
+
|
|
12
10
|
g = geocoder.osm(address).json
|
|
13
11
|
coords = g["lng"], g["lat"]
|
|
14
12
|
return to_gdf(coords, crs=4326).to_crs(crs)
|
|
@@ -16,6 +14,8 @@ def address_to_gdf(address: str, crs=4326) -> GeoDataFrame:
|
|
|
16
14
|
|
|
17
15
|
def address_to_coords(address: str, crs=4326) -> tuple[float, float]:
|
|
18
16
|
"""Takes an address and returns a tuple of xy coordinates."""
|
|
17
|
+
import geocoder
|
|
18
|
+
|
|
19
19
|
g = geocoder.osm(address).json
|
|
20
20
|
coords = g["lng"], g["lat"]
|
|
21
21
|
point = to_gdf(coords, crs=4326).to_crs(crs)
|
|
@@ -83,6 +83,8 @@ def sfilter(
|
|
|
83
83
|
"""
|
|
84
84
|
if not isinstance(gdf, (GeoDataFrame | GeoSeries)):
|
|
85
85
|
raise TypeError(gdf_type_error_message)
|
|
86
|
+
if not len(gdf):
|
|
87
|
+
return gdf
|
|
86
88
|
|
|
87
89
|
other = _sfilter_checks(other, crs=gdf.crs)
|
|
88
90
|
|
|
@@ -159,6 +161,9 @@ def sfilter_split(
|
|
|
159
161
|
>>> not_intersecting = df1.loc[~filt]
|
|
160
162
|
|
|
161
163
|
"""
|
|
164
|
+
if not len(gdf):
|
|
165
|
+
return gdf, gdf
|
|
166
|
+
|
|
162
167
|
if not isinstance(gdf, (GeoDataFrame | GeoSeries)):
|
|
163
168
|
raise TypeError(gdf_type_error_message)
|
|
164
169
|
|
|
@@ -235,6 +240,9 @@ def sfilter_inverse(
|
|
|
235
240
|
"""
|
|
236
241
|
if not isinstance(gdf, (GeoDataFrame | GeoSeries)):
|
|
237
242
|
raise TypeError(gdf_type_error_message)
|
|
243
|
+
if not len(gdf):
|
|
244
|
+
return gdf
|
|
245
|
+
|
|
238
246
|
other = _sfilter_checks(other, crs=gdf.crs)
|
|
239
247
|
indices = _get_sfilter_indices(
|
|
240
248
|
gdf, other, predicate, distance, n_jobs, rtree_runner
|
|
@@ -43,6 +43,7 @@ from ..geopandas_tools.general import clean_geoms
|
|
|
43
43
|
from ..geopandas_tools.general import make_all_singlepart
|
|
44
44
|
from ..geopandas_tools.geometry_types import get_geom_type
|
|
45
45
|
from ..geopandas_tools.geometry_types import to_single_geom_type
|
|
46
|
+
from ..geopandas_tools.sfilter import sfilter
|
|
46
47
|
from ..helpers import _get_file_system
|
|
47
48
|
from ..helpers import dict_zip
|
|
48
49
|
from .wms import WmsLoader
|
|
@@ -487,10 +488,13 @@ class Explore(Map):
|
|
|
487
488
|
if not isinstance(center, GeoDataFrame)
|
|
488
489
|
else center
|
|
489
490
|
)
|
|
491
|
+
centerbuffer = centerpoint.buffer(size)
|
|
490
492
|
|
|
491
493
|
for label, gdf in self._gdfs.items():
|
|
492
494
|
keep_geom_type = False if get_geom_type(gdf) == "mixed" else True
|
|
493
|
-
gdf = gdf.clip(
|
|
495
|
+
gdf = sfilter(gdf, centerbuffer).clip(
|
|
496
|
+
centerbuffer, keep_geom_type=keep_geom_type
|
|
497
|
+
)
|
|
494
498
|
self._gdfs[label] = gdf
|
|
495
499
|
self._gdf = pd.concat(self._gdfs.values(), ignore_index=True)
|
|
496
500
|
|
|
@@ -547,7 +551,7 @@ class Explore(Map):
|
|
|
547
551
|
kwargs.pop("column", None)
|
|
548
552
|
|
|
549
553
|
for label, gdf in self._gdfs.items():
|
|
550
|
-
gdf = gdf.clip(self.mask)
|
|
554
|
+
gdf = sfilter(gdf, self.mask).clip(self.mask)
|
|
551
555
|
collections = gdf.loc[gdf.geom_type == "GeometryCollection"]
|
|
552
556
|
if len(collections):
|
|
553
557
|
collections = make_all_singlepart(collections)
|
|
@@ -295,9 +295,10 @@ class Map:
|
|
|
295
295
|
else:
|
|
296
296
|
return series.astype("string")
|
|
297
297
|
|
|
298
|
-
for
|
|
298
|
+
for label, gdf in self._gdfs.items():
|
|
299
299
|
if self.column in gdf:
|
|
300
|
-
|
|
300
|
+
gdf[self.column] = to_string_via_int(gdf[self.column])
|
|
301
|
+
self._gdfs[label] = gdf
|
|
301
302
|
self._gdf[self.column] = to_string_via_int(self._gdf[self.column])
|
|
302
303
|
|
|
303
304
|
def __bool__(self) -> bool:
|
|
@@ -29,6 +29,7 @@ from ..geopandas_tools.general import get_common_crs
|
|
|
29
29
|
from ..geopandas_tools.general import is_wkt
|
|
30
30
|
from ..geopandas_tools.geocoding import address_to_gdf
|
|
31
31
|
from ..geopandas_tools.geometry_types import get_geom_type
|
|
32
|
+
from ..geopandas_tools.sfilter import sfilter
|
|
32
33
|
from .explore import Explore
|
|
33
34
|
from .map import Map
|
|
34
35
|
from .thematicmap import ThematicMap
|
|
@@ -472,8 +473,10 @@ def clipmap(
|
|
|
472
473
|
if m.gdfs is None and not len(m.rasters):
|
|
473
474
|
return m
|
|
474
475
|
|
|
475
|
-
m._gdfs = {
|
|
476
|
-
|
|
476
|
+
m._gdfs = {
|
|
477
|
+
label: sfilter(gdf, mask).clip(mask) for label, gdf in m._gdfs.items()
|
|
478
|
+
}
|
|
479
|
+
m._gdf = sfilter(m._gdf, mask).clip(mask)
|
|
477
480
|
m._nan_idx = m._gdf[m._column].isna()
|
|
478
481
|
m._get_unique_values()
|
|
479
482
|
m.explore(center=center, size=size)
|
|
@@ -487,8 +490,10 @@ def clipmap(
|
|
|
487
490
|
if m.gdfs is None:
|
|
488
491
|
return m
|
|
489
492
|
|
|
490
|
-
m._gdfs = {
|
|
491
|
-
|
|
493
|
+
m._gdfs = {
|
|
494
|
+
label: sfilter(gdf, mask).clip(mask) for label, gdf in m._gdfs.items()
|
|
495
|
+
}
|
|
496
|
+
m._gdf = sfilter(m._gdf, mask).clip(mask)
|
|
492
497
|
m._nan_idx = m._gdf[m._column].isna()
|
|
493
498
|
m._get_unique_values()
|
|
494
499
|
|
|
@@ -45,14 +45,12 @@ class Points:
|
|
|
45
45
|
return [0 for _ in distances]
|
|
46
46
|
|
|
47
47
|
if rules.nodedist_multiplier and rules.nodedist_kmh:
|
|
48
|
-
raise ValueError(
|
|
49
|
-
"Can only specify one of 'nodedist_multiplier' and 'nodedist_kmh'"
|
|
50
|
-
)
|
|
48
|
+
raise ValueError("Cannot set both 'nodedist_multiplier' and 'nodedist_kmh'")
|
|
51
49
|
|
|
52
50
|
if rules.nodedist_multiplier:
|
|
53
|
-
if rules.weight
|
|
51
|
+
if rules.weight == "minutes":
|
|
54
52
|
raise ValueError(
|
|
55
|
-
"
|
|
53
|
+
"Cannot set 'nodedist_multiplier' when the 'weight' is minutes"
|
|
56
54
|
)
|
|
57
55
|
return [x * rules.nodedist_multiplier for x in distances]
|
|
58
56
|
|
|
@@ -38,10 +38,8 @@ def _get_transform_from_bounds(
|
|
|
38
38
|
obj: GeoDataFrame | GeoSeries | Geometry | tuple, shape: tuple[int, ...]
|
|
39
39
|
) -> Affine:
|
|
40
40
|
minx, miny, maxx, maxy = to_bbox(obj)
|
|
41
|
-
if len(shape)
|
|
42
|
-
height, width = shape
|
|
43
|
-
elif len(shape) == 3:
|
|
44
|
-
_, height, width = shape
|
|
41
|
+
if len(shape) in [2, 3]:
|
|
42
|
+
height, width = shape[-2:]
|
|
45
43
|
else:
|
|
46
44
|
return None
|
|
47
45
|
# raise ValueError(shape)
|
|
@@ -104,7 +102,7 @@ def _array_to_geojson(
|
|
|
104
102
|
return _array_to_geojson_loop(array, transform, mask, processes)
|
|
105
103
|
|
|
106
104
|
except Exception as err:
|
|
107
|
-
raise err.__class__(array.shape
|
|
105
|
+
raise err.__class__(f"{array.shape}: {err}") from err
|
|
108
106
|
|
|
109
107
|
|
|
110
108
|
def _array_to_geojson_loop(array, transform, mask, processes):
|
|
@@ -860,7 +860,6 @@ class Band(_ImageBandBase):
|
|
|
860
860
|
self.transform = _get_transform_from_bounds(self._bounds, shape=data.shape)
|
|
861
861
|
self._from_array = True
|
|
862
862
|
self.values = data
|
|
863
|
-
|
|
864
863
|
self._res = _get_res_from_bounds(self._bounds, self.values.shape)
|
|
865
864
|
|
|
866
865
|
elif not isinstance(data, (str | Path | os.PathLike)):
|
|
@@ -1077,7 +1076,6 @@ class Band(_ImageBandBase):
|
|
|
1077
1076
|
self.transform = None
|
|
1078
1077
|
# activate setter
|
|
1079
1078
|
self.values = self._values
|
|
1080
|
-
|
|
1081
1079
|
return self
|
|
1082
1080
|
|
|
1083
1081
|
if self.has_array and bounds_was_none:
|
|
@@ -1162,8 +1160,7 @@ class Band(_ImageBandBase):
|
|
|
1162
1160
|
values.shape,
|
|
1163
1161
|
)
|
|
1164
1162
|
|
|
1165
|
-
|
|
1166
|
-
|
|
1163
|
+
height, width = values.shape[-2:]
|
|
1167
1164
|
if width and height:
|
|
1168
1165
|
self.transform = rasterio.transform.from_bounds(
|
|
1169
1166
|
*bounds, width, height
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|