ssb-sgis 1.0.2__py3-none-any.whl → 1.0.4__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 +20 -9
- sgis/debug_config.py +24 -0
- sgis/exceptions.py +2 -2
- sgis/geopandas_tools/bounds.py +33 -36
- sgis/geopandas_tools/buffer_dissolve_explode.py +136 -35
- sgis/geopandas_tools/centerlines.py +4 -91
- sgis/geopandas_tools/cleaning.py +1576 -583
- sgis/geopandas_tools/conversion.py +38 -19
- sgis/geopandas_tools/duplicates.py +29 -8
- sgis/geopandas_tools/general.py +263 -100
- sgis/geopandas_tools/geometry_types.py +4 -4
- sgis/geopandas_tools/neighbors.py +19 -15
- sgis/geopandas_tools/overlay.py +2 -2
- sgis/geopandas_tools/point_operations.py +5 -5
- sgis/geopandas_tools/polygon_operations.py +510 -105
- sgis/geopandas_tools/polygons_as_rings.py +40 -8
- sgis/geopandas_tools/sfilter.py +29 -12
- sgis/helpers.py +3 -3
- sgis/io/dapla_functions.py +238 -19
- sgis/io/read_parquet.py +1 -1
- sgis/maps/examine.py +27 -12
- sgis/maps/explore.py +450 -65
- sgis/maps/legend.py +177 -76
- sgis/maps/map.py +206 -103
- sgis/maps/maps.py +178 -105
- sgis/maps/thematicmap.py +243 -83
- sgis/networkanalysis/_service_area.py +6 -1
- sgis/networkanalysis/closing_network_holes.py +2 -2
- sgis/networkanalysis/cutting_lines.py +15 -8
- sgis/networkanalysis/directednetwork.py +1 -1
- sgis/networkanalysis/finding_isolated_networks.py +15 -8
- sgis/networkanalysis/networkanalysis.py +17 -19
- sgis/networkanalysis/networkanalysisrules.py +1 -1
- sgis/networkanalysis/traveling_salesman.py +1 -1
- sgis/parallel/parallel.py +64 -27
- sgis/raster/__init__.py +0 -6
- sgis/raster/base.py +208 -0
- sgis/raster/cube.py +54 -8
- sgis/raster/image_collection.py +3257 -0
- sgis/raster/indices.py +17 -5
- sgis/raster/raster.py +138 -243
- sgis/raster/sentinel_config.py +120 -0
- sgis/raster/zonal.py +0 -1
- {ssb_sgis-1.0.2.dist-info → ssb_sgis-1.0.4.dist-info}/METADATA +6 -7
- ssb_sgis-1.0.4.dist-info/RECORD +62 -0
- sgis/raster/methods_as_functions.py +0 -0
- sgis/raster/torchgeo.py +0 -171
- ssb_sgis-1.0.2.dist-info/RECORD +0 -61
- {ssb_sgis-1.0.2.dist-info → ssb_sgis-1.0.4.dist-info}/LICENSE +0 -0
- {ssb_sgis-1.0.2.dist-info → ssb_sgis-1.0.4.dist-info}/WHEEL +0 -0
|
@@ -64,7 +64,7 @@ def to_single_geom_type(
|
|
|
64
64
|
ValueError: If 'geom_type' is neither 'polygon', 'line' or 'point'.
|
|
65
65
|
|
|
66
66
|
Examples:
|
|
67
|
-
|
|
67
|
+
---------
|
|
68
68
|
First create a GeoDataFrame of mixed geometries.
|
|
69
69
|
|
|
70
70
|
>>> from sgis import to_gdf, to_single_geom_type
|
|
@@ -138,7 +138,7 @@ def to_single_geom_type(
|
|
|
138
138
|
|
|
139
139
|
def _shapely_to_single_geom_type(geom: Geometry, geom_type: str) -> Geometry:
|
|
140
140
|
parts = shapely.get_parts(geom)
|
|
141
|
-
return shapely.
|
|
141
|
+
return shapely.union_all(
|
|
142
142
|
[part for part in parts if geom_type.lower() in part.geom_type.lower()]
|
|
143
143
|
)
|
|
144
144
|
|
|
@@ -156,7 +156,7 @@ def get_geom_type(gdf: GeoDataFrame | GeoSeries) -> str:
|
|
|
156
156
|
TypeError: If 'gdf' is not of type GeoDataFrame or GeoSeries.
|
|
157
157
|
|
|
158
158
|
Examples:
|
|
159
|
-
|
|
159
|
+
---------
|
|
160
160
|
>>> from sgis import to_gdf, get_geom_type
|
|
161
161
|
>>> gdf = to_gdf([0, 0])
|
|
162
162
|
>>> gdf
|
|
@@ -204,7 +204,7 @@ def is_single_geom_type(gdf: GeoDataFrame | GeoSeries) -> bool:
|
|
|
204
204
|
TypeError: If 'gdf' is not of type GeoDataFrame or GeoSeries.
|
|
205
205
|
|
|
206
206
|
Examples:
|
|
207
|
-
|
|
207
|
+
---------
|
|
208
208
|
>>> from sgis import to_gdf, get_geom_type
|
|
209
209
|
>>> gdf = to_gdf([0, 0])
|
|
210
210
|
>>> gdf
|
|
@@ -13,6 +13,7 @@ import shapely
|
|
|
13
13
|
from geopandas import GeoDataFrame
|
|
14
14
|
from geopandas import GeoSeries
|
|
15
15
|
from pandas import DataFrame
|
|
16
|
+
from pandas import MultiIndex
|
|
16
17
|
from pandas import Series
|
|
17
18
|
from sklearn.neighbors import NearestNeighbors
|
|
18
19
|
|
|
@@ -50,7 +51,7 @@ def get_neighbor_indices(
|
|
|
50
51
|
system.
|
|
51
52
|
|
|
52
53
|
Examples:
|
|
53
|
-
|
|
54
|
+
---------
|
|
54
55
|
>>> from sgis import get_neighbor_indices, to_gdf
|
|
55
56
|
>>> points = to_gdf([(0, 0), (0.5, 0.5)])
|
|
56
57
|
>>> points
|
|
@@ -97,29 +98,32 @@ def get_neighbor_indices(
|
|
|
97
98
|
['a' 'a' 'b' 'b']
|
|
98
99
|
|
|
99
100
|
"""
|
|
101
|
+
if isinstance(gdf.index, MultiIndex) or isinstance(neighbors.index, MultiIndex):
|
|
102
|
+
raise ValueError("get_neighbor_indices not implemented for pandas.MultiIndex")
|
|
100
103
|
if gdf.crs != neighbors.crs:
|
|
101
104
|
raise ValueError(f"'crs' mismatch. Got {gdf.crs} and {neighbors.crs}")
|
|
102
105
|
|
|
103
106
|
if isinstance(neighbors, GeoSeries):
|
|
104
107
|
neighbors = neighbors.to_frame()
|
|
108
|
+
else:
|
|
109
|
+
neighbors = neighbors[[neighbors._geometry_column_name]]
|
|
105
110
|
|
|
106
111
|
# buffer and keep only geometry column
|
|
107
112
|
if max_distance and predicate != "nearest":
|
|
108
|
-
gdf = gdf.buffer(max_distance).to_frame()
|
|
113
|
+
gdf = gdf.buffer(max_distance).to_frame("geometry")
|
|
109
114
|
else:
|
|
110
|
-
gdf = gdf.geometry.to_frame()
|
|
115
|
+
gdf = gdf.geometry.to_frame("geometry")
|
|
116
|
+
|
|
117
|
+
neighbors.index.name = None
|
|
118
|
+
gdf.index.name = None
|
|
111
119
|
|
|
112
120
|
if predicate == "nearest":
|
|
113
121
|
max_distance = None if max_distance == 0 else max_distance
|
|
114
|
-
joined = gdf.sjoin_nearest(
|
|
115
|
-
neighbors, how="inner", max_distance=max_distance
|
|
116
|
-
).rename(columns={"index_right": "neighbor_index"}, errors="raise")
|
|
122
|
+
joined = gdf.sjoin_nearest(neighbors, how="inner", max_distance=max_distance)
|
|
117
123
|
else:
|
|
118
|
-
joined = gdf.sjoin(neighbors, how="inner", predicate=predicate)
|
|
119
|
-
columns={"index_right": "neighbor_index"}, errors="raise"
|
|
120
|
-
)
|
|
124
|
+
joined = gdf.sjoin(neighbors, how="inner", predicate=predicate)
|
|
121
125
|
|
|
122
|
-
return joined["neighbor_index"]
|
|
126
|
+
return joined.rename(columns={"index_right": "neighbor_index"})["neighbor_index"]
|
|
123
127
|
|
|
124
128
|
|
|
125
129
|
def get_neighbor_dfs(
|
|
@@ -153,7 +157,7 @@ def get_all_distances(
|
|
|
153
157
|
not the same.
|
|
154
158
|
|
|
155
159
|
Examples:
|
|
156
|
-
|
|
160
|
+
---------
|
|
157
161
|
>>> from sgis import get_all_distances, random_points
|
|
158
162
|
>>> points = random_points(100)
|
|
159
163
|
>>> neighbors = random_points(100)
|
|
@@ -297,7 +301,7 @@ def get_k_nearest_neighbors(
|
|
|
297
301
|
not the same.
|
|
298
302
|
|
|
299
303
|
Examples:
|
|
300
|
-
|
|
304
|
+
---------
|
|
301
305
|
Make some random points.
|
|
302
306
|
|
|
303
307
|
>>> from sgis import get_k_nearest_neighbors, random_points
|
|
@@ -469,6 +473,6 @@ def _get_edges(
|
|
|
469
473
|
Returns:
|
|
470
474
|
A 2d numpy array of edges (from-to indices).
|
|
471
475
|
"""
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
)
|
|
476
|
+
row_indices = np.arange(len(indices)).reshape(-1, 1)
|
|
477
|
+
|
|
478
|
+
return np.stack((np.broadcast_to(row_indices, indices.shape), indices), axis=-1)
|
sgis/geopandas_tools/overlay.py
CHANGED
|
@@ -238,8 +238,8 @@ def _shapely_pd_overlay(
|
|
|
238
238
|
left, right = tree.query(df1.geometry.values, predicate=predicate)
|
|
239
239
|
|
|
240
240
|
pairs = _get_intersects_pairs(df1, df2, left, right, rsuffix)
|
|
241
|
-
assert pairs.geometry.notna().all()
|
|
242
|
-
assert pairs.geom_right.notna().all()
|
|
241
|
+
assert pairs.geometry.notna().all(), pairs.geometry
|
|
242
|
+
assert pairs.geom_right.notna().all(), pairs.geom_right
|
|
243
243
|
|
|
244
244
|
if how == "intersection":
|
|
245
245
|
overlayed = [
|
|
@@ -5,7 +5,7 @@ import pandas as pd
|
|
|
5
5
|
from geopandas import GeoDataFrame
|
|
6
6
|
from geopandas import GeoSeries
|
|
7
7
|
from shapely import distance
|
|
8
|
-
from shapely import
|
|
8
|
+
from shapely import union_all
|
|
9
9
|
from shapely.ops import nearest_points
|
|
10
10
|
|
|
11
11
|
from ..geopandas_tools.geometry_types import get_geom_type
|
|
@@ -48,7 +48,7 @@ def snap_within_distance(
|
|
|
48
48
|
vertices.
|
|
49
49
|
|
|
50
50
|
Examples:
|
|
51
|
-
|
|
51
|
+
---------
|
|
52
52
|
Create som points.
|
|
53
53
|
|
|
54
54
|
>>> from sgis import snap_within_distance, to_gdf
|
|
@@ -136,7 +136,7 @@ def snap_all(
|
|
|
136
136
|
vertices.
|
|
137
137
|
|
|
138
138
|
Examples:
|
|
139
|
-
|
|
139
|
+
---------
|
|
140
140
|
Create som points.
|
|
141
141
|
|
|
142
142
|
>>> from sgis import snap_all, to_gdf
|
|
@@ -201,9 +201,9 @@ def _shapely_snap(
|
|
|
201
201
|
max_distance: int | float | None = None,
|
|
202
202
|
) -> GeoSeries:
|
|
203
203
|
try:
|
|
204
|
-
unioned = to.
|
|
204
|
+
unioned = union_all(to.geometry.values)
|
|
205
205
|
except AttributeError:
|
|
206
|
-
unioned =
|
|
206
|
+
unioned = union_all(to)
|
|
207
207
|
|
|
208
208
|
nearest = nearest_points(points, unioned)[1]
|
|
209
209
|
|