ssb-sgis 1.0.2__tar.gz → 1.0.3__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.0.2 → ssb_sgis-1.0.3}/PKG-INFO +1 -1
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/pyproject.toml +1 -1
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/__init__.py +10 -6
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/exceptions.py +2 -2
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/geopandas_tools/bounds.py +17 -15
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/geopandas_tools/buffer_dissolve_explode.py +24 -5
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/geopandas_tools/conversion.py +15 -6
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/geopandas_tools/duplicates.py +2 -2
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/geopandas_tools/general.py +9 -5
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/geopandas_tools/geometry_types.py +3 -3
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/geopandas_tools/neighbors.py +3 -3
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/geopandas_tools/point_operations.py +2 -2
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/geopandas_tools/polygon_operations.py +5 -5
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/geopandas_tools/sfilter.py +3 -3
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/helpers.py +3 -3
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/io/read_parquet.py +1 -1
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/maps/examine.py +16 -2
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/maps/explore.py +370 -57
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/maps/legend.py +164 -72
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/maps/map.py +184 -90
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/maps/maps.py +92 -90
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/maps/thematicmap.py +236 -83
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/networkanalysis/closing_network_holes.py +2 -2
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/networkanalysis/cutting_lines.py +3 -3
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/networkanalysis/directednetwork.py +1 -1
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/networkanalysis/finding_isolated_networks.py +2 -2
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/networkanalysis/networkanalysis.py +7 -7
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/networkanalysis/networkanalysisrules.py +1 -1
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/networkanalysis/traveling_salesman.py +1 -1
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/parallel/parallel.py +39 -19
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/raster/cube.py +51 -5
- ssb_sgis-1.0.3/src/sgis/raster/image_collection.py +2560 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/raster/indices.py +14 -5
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/raster/raster.py +131 -236
- ssb_sgis-1.0.3/src/sgis/raster/sentinel_config.py +104 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/raster/zonal.py +0 -1
- ssb_sgis-1.0.2/src/sgis/raster/__init__.py +0 -6
- ssb_sgis-1.0.2/src/sgis/raster/torchgeo.py +0 -171
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/LICENSE +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/README.md +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/geopandas_tools/__init__.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/geopandas_tools/centerlines.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/geopandas_tools/cleaning.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/geopandas_tools/geocoding.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/geopandas_tools/overlay.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/geopandas_tools/polygons_as_rings.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/io/_is_dapla.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/io/dapla_functions.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/io/opener.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/maps/__init__.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/maps/httpserver.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/maps/tilesources.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/networkanalysis/__init__.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/networkanalysis/_get_route.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/networkanalysis/_od_cost_matrix.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/networkanalysis/_points.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/networkanalysis/_service_area.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/networkanalysis/network.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/networkanalysis/nodes.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/py.typed +0 -0
- /ssb_sgis-1.0.2/src/sgis/raster/methods_as_functions.py → /ssb_sgis-1.0.3/src/sgis/raster/__init__.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/raster/base.py +0 -0
- {ssb_sgis-1.0.2 → ssb_sgis-1.0.3}/src/sgis/raster/cubebase.py +0 -0
|
@@ -115,12 +115,16 @@ from .networkanalysis.traveling_salesman import traveling_salesman_problem
|
|
|
115
115
|
from .parallel.parallel import Parallel
|
|
116
116
|
from .parallel.parallel import parallel_overlay
|
|
117
117
|
from .raster.cube import DataCube
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
from .raster.cube import concat_cubes
|
|
119
|
+
from .raster.image_collection import Band
|
|
120
|
+
from .raster.image_collection import Image
|
|
121
|
+
from .raster.image_collection import ImageCollection
|
|
122
|
+
from .raster.image_collection import Sentinel2Band
|
|
123
|
+
from .raster.image_collection import Sentinel2CloudlessCollection
|
|
124
|
+
from .raster.image_collection import Sentinel2CloudlessImage
|
|
125
|
+
from .raster.image_collection import Sentinel2Collection
|
|
126
|
+
from .raster.image_collection import Sentinel2Image
|
|
127
|
+
from .raster.image_collection import concat_image_collections
|
|
124
128
|
|
|
125
129
|
try:
|
|
126
130
|
from .io.dapla_functions import check_files
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Some small exception classes."""
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
class NoPointsWithinSearchToleranceError(
|
|
4
|
+
class NoPointsWithinSearchToleranceError(ValueError):
|
|
5
5
|
"""Exception for when the points are too far away from the network."""
|
|
6
6
|
|
|
7
7
|
def __init__(
|
|
@@ -19,5 +19,5 @@ class NoPointsWithinSearchToleranceError(Exception):
|
|
|
19
19
|
)
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
class ZeroLinesError(
|
|
22
|
+
class ZeroLinesError(ValueError):
|
|
23
23
|
"""DataFrame has 0 rows."""
|
|
@@ -37,7 +37,7 @@ class Gridlooper:
|
|
|
37
37
|
Defaults to True.
|
|
38
38
|
|
|
39
39
|
Examples:
|
|
40
|
-
|
|
40
|
+
---------
|
|
41
41
|
Get some points and some polygons.
|
|
42
42
|
|
|
43
43
|
>>> import sgis as sg
|
|
@@ -222,7 +222,7 @@ def gridloop(
|
|
|
222
222
|
TypeError: If args or kwargs has a wrong type
|
|
223
223
|
|
|
224
224
|
Examples:
|
|
225
|
-
|
|
225
|
+
---------
|
|
226
226
|
Get some points and some polygons.
|
|
227
227
|
|
|
228
228
|
>>> import sgis as sg
|
|
@@ -442,7 +442,7 @@ def make_grid(
|
|
|
442
442
|
obj: GeoDataFrame | GeoSeries | Geometry | tuple,
|
|
443
443
|
gridsize: int | float,
|
|
444
444
|
*,
|
|
445
|
-
crs: CRS = None,
|
|
445
|
+
crs: CRS | None = None,
|
|
446
446
|
clip_to_bounds: bool = False,
|
|
447
447
|
) -> GeoDataFrame:
|
|
448
448
|
"""Create a polygon grid around geometries.
|
|
@@ -467,10 +467,6 @@ def make_grid(
|
|
|
467
467
|
"""
|
|
468
468
|
if isinstance(obj, (GeoDataFrame | GeoSeries)):
|
|
469
469
|
crs = obj.crs or crs
|
|
470
|
-
elif not crs:
|
|
471
|
-
raise ValueError(
|
|
472
|
-
"'crs' cannot be None when 'obj' is not GeoDataFrame/GeoSeries."
|
|
473
|
-
)
|
|
474
470
|
if hasattr(obj, "__len__") and not len(obj):
|
|
475
471
|
return GeoDataFrame({"geometry": []}, crs=crs)
|
|
476
472
|
|
|
@@ -617,7 +613,7 @@ def bounds_to_polygon(
|
|
|
617
613
|
GeoDataFrame of box polygons with length and index of 'gdf'.
|
|
618
614
|
|
|
619
615
|
Examples:
|
|
620
|
-
|
|
616
|
+
---------
|
|
621
617
|
>>> import sgis as sg
|
|
622
618
|
>>> gdf = sg.to_gdf([MultiPoint([(0, 0), (1, 1)]), Point(0, 0)])
|
|
623
619
|
>>> gdf
|
|
@@ -652,7 +648,7 @@ def bounds_to_points(
|
|
|
652
648
|
GeoDataFrame of multipoints with same length and index as 'gdf'.
|
|
653
649
|
|
|
654
650
|
Examples:
|
|
655
|
-
|
|
651
|
+
---------
|
|
656
652
|
>>> import sgis as sg
|
|
657
653
|
>>> gdf = sg.to_gdf([MultiPoint([(0, 0), (1, 1)]), Point(0, 0)])
|
|
658
654
|
>>> gdf
|
|
@@ -680,13 +676,19 @@ def get_total_bounds(
|
|
|
680
676
|
for obj in geometries:
|
|
681
677
|
try:
|
|
682
678
|
minx, miny, maxx, maxy = to_bbox(obj)
|
|
679
|
+
xs += [minx, maxx]
|
|
680
|
+
ys += [miny, maxy]
|
|
683
681
|
except Exception as e:
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
682
|
+
try:
|
|
683
|
+
for x in obj:
|
|
684
|
+
minx, miny, maxx, maxy = to_bbox(x)
|
|
685
|
+
xs += [minx, maxx]
|
|
686
|
+
ys += [miny, maxy]
|
|
687
|
+
except Exception as e2:
|
|
688
|
+
if strict:
|
|
689
|
+
raise e2 from e
|
|
690
|
+
else:
|
|
691
|
+
continue
|
|
690
692
|
return min(xs), min(ys), max(xs), max(ys)
|
|
691
693
|
|
|
692
694
|
|
|
@@ -52,6 +52,7 @@ def buffdissexp(
|
|
|
52
52
|
copy: bool = True,
|
|
53
53
|
grid_size: float | int | None = None,
|
|
54
54
|
n_jobs: int = 1,
|
|
55
|
+
join_style: int | str = "round",
|
|
55
56
|
**dissolve_kwargs,
|
|
56
57
|
) -> GeoDataFrame:
|
|
57
58
|
"""Buffers and dissolves overlapping geometries.
|
|
@@ -71,6 +72,7 @@ def buffdissexp(
|
|
|
71
72
|
copy: Whether to copy the GeoDataFrame before buffering. Defaults to True.
|
|
72
73
|
grid_size: Rounding of the coordinates. Defaults to None.
|
|
73
74
|
n_jobs: Number of threads to use. Defaults to 1.
|
|
75
|
+
join_style: Buffer join style.
|
|
74
76
|
**dissolve_kwargs: additional keyword arguments passed to geopandas' dissolve.
|
|
75
77
|
|
|
76
78
|
Returns:
|
|
@@ -85,6 +87,7 @@ def buffdissexp(
|
|
|
85
87
|
copy=copy,
|
|
86
88
|
grid_size=grid_size,
|
|
87
89
|
n_jobs=n_jobs,
|
|
90
|
+
join_style=join_style,
|
|
88
91
|
**dissolve_kwargs,
|
|
89
92
|
)
|
|
90
93
|
|
|
@@ -99,6 +102,7 @@ def buffdiss(
|
|
|
99
102
|
resolution: int = 50,
|
|
100
103
|
copy: bool = True,
|
|
101
104
|
n_jobs: int = 1,
|
|
105
|
+
join_style: int | str = "round",
|
|
102
106
|
**dissolve_kwargs,
|
|
103
107
|
) -> GeoDataFrame:
|
|
104
108
|
"""Buffers and dissolves geometries.
|
|
@@ -114,6 +118,7 @@ def buffdiss(
|
|
|
114
118
|
the geometry by
|
|
115
119
|
resolution: The number of segments used to approximate a quarter circle.
|
|
116
120
|
Here defaults to 50, as opposed to the default 16 in geopandas.
|
|
121
|
+
join_style: Buffer join style.
|
|
117
122
|
copy: Whether to copy the GeoDataFrame before buffering. Defaults to True.
|
|
118
123
|
n_jobs: Number of threads to use. Defaults to 1.
|
|
119
124
|
**dissolve_kwargs: additional keyword arguments passed to geopandas' dissolve.
|
|
@@ -122,7 +127,7 @@ def buffdiss(
|
|
|
122
127
|
A buffered GeoDataFrame where geometries are dissolved.
|
|
123
128
|
|
|
124
129
|
Examples:
|
|
125
|
-
|
|
130
|
+
---------
|
|
126
131
|
Create some random points.
|
|
127
132
|
|
|
128
133
|
>>> import sgis as sg
|
|
@@ -169,7 +174,9 @@ def buffdiss(
|
|
|
169
174
|
1 b MULTIPOLYGON (((258404.858 6647830.931, 258404... 0.687635
|
|
170
175
|
2 d MULTIPOLYGON (((258180.258 6647935.731, 258179... 0.580157
|
|
171
176
|
"""
|
|
172
|
-
buffered = buff(
|
|
177
|
+
buffered = buff(
|
|
178
|
+
gdf, distance, resolution=resolution, copy=copy, join_style=join_style
|
|
179
|
+
)
|
|
173
180
|
|
|
174
181
|
return _dissolve(buffered, n_jobs=n_jobs, **dissolve_kwargs)
|
|
175
182
|
|
|
@@ -462,6 +469,7 @@ def buffdissexp_by_cluster(
|
|
|
462
469
|
resolution: int = 50,
|
|
463
470
|
copy: bool = True,
|
|
464
471
|
n_jobs: int = 1,
|
|
472
|
+
join_style: int | str = "round",
|
|
465
473
|
**dissolve_kwargs,
|
|
466
474
|
) -> GeoDataFrame:
|
|
467
475
|
"""Buffers and dissolves overlapping geometries.
|
|
@@ -480,6 +488,7 @@ def buffdissexp_by_cluster(
|
|
|
480
488
|
the geometry by
|
|
481
489
|
resolution: The number of segments used to approximate a quarter circle.
|
|
482
490
|
Here defaults to 50, as opposed to the default 16 in geopandas.
|
|
491
|
+
join_style: Buffer join style.
|
|
483
492
|
copy: Whether to copy the GeoDataFrame before buffering. Defaults to True.
|
|
484
493
|
n_jobs: int = 1,
|
|
485
494
|
**dissolve_kwargs: additional keyword arguments passed to geopandas' dissolve.
|
|
@@ -487,7 +496,13 @@ def buffdissexp_by_cluster(
|
|
|
487
496
|
Returns:
|
|
488
497
|
A buffered GeoDataFrame where overlapping geometries are dissolved.
|
|
489
498
|
"""
|
|
490
|
-
buffered = buff(
|
|
499
|
+
buffered = buff(
|
|
500
|
+
gdf,
|
|
501
|
+
distance,
|
|
502
|
+
resolution=resolution,
|
|
503
|
+
copy=copy,
|
|
504
|
+
join_style=join_style,
|
|
505
|
+
)
|
|
491
506
|
return dissexp_by_cluster(buffered, n_jobs=n_jobs, **dissolve_kwargs)
|
|
492
507
|
|
|
493
508
|
|
|
@@ -496,6 +511,7 @@ def buff(
|
|
|
496
511
|
distance: int | float,
|
|
497
512
|
resolution: int = 50,
|
|
498
513
|
copy: bool = True,
|
|
514
|
+
join_style: int | str = "round",
|
|
499
515
|
**buffer_kwargs,
|
|
500
516
|
) -> GeoDataFrame:
|
|
501
517
|
"""Buffers a GeoDataFrame with high resolution and returns a new GeoDataFrame.
|
|
@@ -506,6 +522,7 @@ def buff(
|
|
|
506
522
|
the geometry by
|
|
507
523
|
resolution: The number of segments used to approximate a quarter circle.
|
|
508
524
|
Here defaults to 50, as opposed to the default 16 in geopandas.
|
|
525
|
+
join_style: Buffer join style.
|
|
509
526
|
copy: Whether to copy the GeoDataFrame before buffering. Defaults to True.
|
|
510
527
|
**buffer_kwargs: additional keyword arguments passed to geopandas' buffer.
|
|
511
528
|
|
|
@@ -513,13 +530,15 @@ def buff(
|
|
|
513
530
|
A buffered GeoDataFrame.
|
|
514
531
|
"""
|
|
515
532
|
if isinstance(gdf, GeoSeries):
|
|
516
|
-
return gdf.buffer(
|
|
533
|
+
return gdf.buffer(
|
|
534
|
+
distance, resolution=resolution, join_style=join_style, **buffer_kwargs
|
|
535
|
+
).make_valid()
|
|
517
536
|
|
|
518
537
|
if copy:
|
|
519
538
|
gdf = gdf.copy()
|
|
520
539
|
|
|
521
540
|
gdf[gdf._geometry_column_name] = gdf.buffer(
|
|
522
|
-
distance, resolution=resolution, **buffer_kwargs
|
|
541
|
+
distance, resolution=resolution, join_style=join_style, **buffer_kwargs
|
|
523
542
|
).make_valid()
|
|
524
543
|
|
|
525
544
|
return gdf
|
|
@@ -90,8 +90,10 @@ def to_shapely(obj: Any) -> Geometry:
|
|
|
90
90
|
return obj
|
|
91
91
|
if not hasattr(obj, "__iter__"):
|
|
92
92
|
raise TypeError(type(obj))
|
|
93
|
-
|
|
93
|
+
try:
|
|
94
94
|
return obj.unary_union
|
|
95
|
+
except AttributeError:
|
|
96
|
+
pass
|
|
95
97
|
try:
|
|
96
98
|
return Point(*obj)
|
|
97
99
|
except TypeError:
|
|
@@ -108,6 +110,7 @@ def to_shapely(obj: Any) -> Geometry:
|
|
|
108
110
|
return shapely.wkb.loads(obj)
|
|
109
111
|
except TypeError:
|
|
110
112
|
pass
|
|
113
|
+
raise TypeError(type(obj))
|
|
111
114
|
|
|
112
115
|
|
|
113
116
|
def to_bbox(
|
|
@@ -122,9 +125,15 @@ def to_bbox(
|
|
|
122
125
|
"xmin", "ymin", "xmax", "ymax".
|
|
123
126
|
"""
|
|
124
127
|
if isinstance(obj, (GeoDataFrame, GeoSeries)):
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return
|
|
128
|
+
bounds = tuple(obj.total_bounds)
|
|
129
|
+
assert isinstance(bounds, tuple)
|
|
130
|
+
return bounds
|
|
131
|
+
try:
|
|
132
|
+
bounds = tuple(obj.bounds)
|
|
133
|
+
assert isinstance(bounds, tuple)
|
|
134
|
+
return bounds
|
|
135
|
+
except Exception:
|
|
136
|
+
pass
|
|
128
137
|
|
|
129
138
|
try:
|
|
130
139
|
minx = int(np.min(obj["minx"])) # type: ignore [index]
|
|
@@ -195,7 +204,7 @@ def coordinate_array(
|
|
|
195
204
|
np.ndarray of np.ndarrays of coordinates.
|
|
196
205
|
|
|
197
206
|
Examples:
|
|
198
|
-
|
|
207
|
+
---------
|
|
199
208
|
>>> import sgis as sg
|
|
200
209
|
>>> points = sg.to_gdf(
|
|
201
210
|
... [
|
|
@@ -279,7 +288,7 @@ def to_gdf(
|
|
|
279
288
|
A GeoDataFrame with one column, the geometry column.
|
|
280
289
|
|
|
281
290
|
Examples:
|
|
282
|
-
|
|
291
|
+
---------
|
|
283
292
|
>>> import sgis as sg
|
|
284
293
|
>>> coords = (10, 60)
|
|
285
294
|
>>> sg.to_gdf(coords, crs=4326)
|
|
@@ -54,7 +54,7 @@ def update_geometries(
|
|
|
54
54
|
predicate: Spatial predicate for the spatial tree.
|
|
55
55
|
|
|
56
56
|
Example:
|
|
57
|
-
|
|
57
|
+
--------
|
|
58
58
|
Create two circles and get the overlap.
|
|
59
59
|
|
|
60
60
|
>>> import sgis as sg
|
|
@@ -213,7 +213,7 @@ def get_intersections(
|
|
|
213
213
|
A GeoDataFrame of the overlapping polygons.
|
|
214
214
|
|
|
215
215
|
Examples:
|
|
216
|
-
|
|
216
|
+
---------
|
|
217
217
|
Create three partially overlapping polygons.
|
|
218
218
|
|
|
219
219
|
>>> import sgis as sg
|
|
@@ -4,7 +4,6 @@ from collections.abc import Hashable
|
|
|
4
4
|
from collections.abc import Iterable
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
|
-
import dask_geopandas
|
|
8
7
|
import joblib
|
|
9
8
|
import numpy as np
|
|
10
9
|
import pandas as pd
|
|
@@ -27,6 +26,11 @@ from shapely import unary_union
|
|
|
27
26
|
from shapely.geometry import LineString
|
|
28
27
|
from shapely.geometry import Point
|
|
29
28
|
|
|
29
|
+
try:
|
|
30
|
+
import dask_geopandas
|
|
31
|
+
except ImportError:
|
|
32
|
+
pass
|
|
33
|
+
|
|
30
34
|
from .geometry_types import get_geom_type
|
|
31
35
|
from .geometry_types import make_all_singlepart
|
|
32
36
|
from .geometry_types import to_single_geom_type
|
|
@@ -164,7 +168,7 @@ def clean_geoms(
|
|
|
164
168
|
non-empty and not-NaN/-None geometries.
|
|
165
169
|
|
|
166
170
|
Examples:
|
|
167
|
-
|
|
171
|
+
---------
|
|
168
172
|
>>> import sgis as sg
|
|
169
173
|
>>> import pandas as pd
|
|
170
174
|
>>> from shapely import wkt
|
|
@@ -281,7 +285,7 @@ def sort_large_first(gdf: GeoDataFrame | GeoSeries) -> GeoDataFrame | GeoSeries:
|
|
|
281
285
|
A GeoDataFrame or GeoSeries sorted from large to small in area.
|
|
282
286
|
|
|
283
287
|
Examples:
|
|
284
|
-
|
|
288
|
+
---------
|
|
285
289
|
Create GeoDataFrame with NaN values.
|
|
286
290
|
|
|
287
291
|
>>> import sgis as sg
|
|
@@ -423,7 +427,7 @@ def random_points(n: int, loc: float | int = 0.5) -> GeoDataFrame:
|
|
|
423
427
|
A GeoDataFrame of points with n rows.
|
|
424
428
|
|
|
425
429
|
Examples:
|
|
426
|
-
|
|
430
|
+
---------
|
|
427
431
|
>>> import sgis as sg
|
|
428
432
|
>>> points = sg.random_points(10_000)
|
|
429
433
|
>>> points
|
|
@@ -523,7 +527,7 @@ def to_lines(*gdfs: GeoDataFrame, copy: bool = True) -> GeoDataFrame:
|
|
|
523
527
|
always ignores the index.
|
|
524
528
|
|
|
525
529
|
Examples:
|
|
526
|
-
|
|
530
|
+
---------
|
|
527
531
|
Convert single polygon to linestring.
|
|
528
532
|
|
|
529
533
|
>>> import sgis as sg
|
|
@@ -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
|
|
@@ -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
|
|
@@ -50,7 +50,7 @@ def get_neighbor_indices(
|
|
|
50
50
|
system.
|
|
51
51
|
|
|
52
52
|
Examples:
|
|
53
|
-
|
|
53
|
+
---------
|
|
54
54
|
>>> from sgis import get_neighbor_indices, to_gdf
|
|
55
55
|
>>> points = to_gdf([(0, 0), (0.5, 0.5)])
|
|
56
56
|
>>> points
|
|
@@ -153,7 +153,7 @@ def get_all_distances(
|
|
|
153
153
|
not the same.
|
|
154
154
|
|
|
155
155
|
Examples:
|
|
156
|
-
|
|
156
|
+
---------
|
|
157
157
|
>>> from sgis import get_all_distances, random_points
|
|
158
158
|
>>> points = random_points(100)
|
|
159
159
|
>>> neighbors = random_points(100)
|
|
@@ -297,7 +297,7 @@ def get_k_nearest_neighbors(
|
|
|
297
297
|
not the same.
|
|
298
298
|
|
|
299
299
|
Examples:
|
|
300
|
-
|
|
300
|
+
---------
|
|
301
301
|
Make some random points.
|
|
302
302
|
|
|
303
303
|
>>> from sgis import get_k_nearest_neighbors, random_points
|
|
@@ -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
|
|
@@ -70,7 +70,7 @@ def get_polygon_clusters(
|
|
|
70
70
|
One or more GeoDataFrames (same amount as was given) with a new cluster column.
|
|
71
71
|
|
|
72
72
|
Examples:
|
|
73
|
-
|
|
73
|
+
---------
|
|
74
74
|
Create geometries with three clusters of overlapping polygons.
|
|
75
75
|
|
|
76
76
|
>>> import sgis as sg
|
|
@@ -250,7 +250,7 @@ def eliminate_by_longest(
|
|
|
250
250
|
If multiple GeoDataFrame are passed as 'gdf', they are returned as a tuple.
|
|
251
251
|
|
|
252
252
|
Examples:
|
|
253
|
-
|
|
253
|
+
---------
|
|
254
254
|
Create two polygons with a sliver in between:
|
|
255
255
|
|
|
256
256
|
>>> sliver = sg.to_gdf(Polygon([(0, 0), (0.1, 1), (0, 2), (-0.1, 1)]))
|
|
@@ -426,7 +426,7 @@ def eliminate_by_largest(
|
|
|
426
426
|
If multiple GeoDataFrame are passed as 'gdf', they are returned as a tuple.
|
|
427
427
|
|
|
428
428
|
Examples:
|
|
429
|
-
|
|
429
|
+
---------
|
|
430
430
|
Create two polygons with a sliver in between:
|
|
431
431
|
|
|
432
432
|
>>> sliver = sg.to_gdf(Polygon([(0, 0), (0.1, 1), (0, 2), (-0.1, 1)]))
|
|
@@ -803,7 +803,7 @@ def close_all_holes(
|
|
|
803
803
|
column.
|
|
804
804
|
|
|
805
805
|
Examples:
|
|
806
|
-
|
|
806
|
+
---------
|
|
807
807
|
Let's create a circle with a hole in it.
|
|
808
808
|
|
|
809
809
|
>>> point = sg.to_gdf([260000, 6650000], crs=25833)
|
|
@@ -892,7 +892,7 @@ def close_small_holes(
|
|
|
892
892
|
ValueError: If both 'max_m2' and 'max_km2' is given.
|
|
893
893
|
|
|
894
894
|
Examples:
|
|
895
|
-
|
|
895
|
+
---------
|
|
896
896
|
Let's create a circle with a hole in it.
|
|
897
897
|
|
|
898
898
|
>>> point = sg.to_gdf([260000, 6650000], crs=25833)
|
|
@@ -35,7 +35,7 @@ def sfilter(
|
|
|
35
35
|
spatial predicate with 'other'.
|
|
36
36
|
|
|
37
37
|
Examples:
|
|
38
|
-
|
|
38
|
+
---------
|
|
39
39
|
>>> import sgis as sg
|
|
40
40
|
>>> df1 = sg.to_gdf([(0, 0), (0, 1)])
|
|
41
41
|
>>> df1
|
|
@@ -101,7 +101,7 @@ def sfilter_split(
|
|
|
101
101
|
and one with the rows that do not.
|
|
102
102
|
|
|
103
103
|
Examples:
|
|
104
|
-
|
|
104
|
+
---------
|
|
105
105
|
>>> import sgis as sg
|
|
106
106
|
>>> df1 = sg.to_gdf([(0, 0), (0, 1)])
|
|
107
107
|
>>> df1
|
|
@@ -172,7 +172,7 @@ def sfilter_inverse(
|
|
|
172
172
|
spatial predicate with 'other'.
|
|
173
173
|
|
|
174
174
|
Examples:
|
|
175
|
-
|
|
175
|
+
---------
|
|
176
176
|
>>> import sgis as sg
|
|
177
177
|
>>> df1 = sg.to_gdf([(0, 0), (0, 1)])
|
|
178
178
|
>>> df1
|
|
@@ -141,7 +141,7 @@ def get_all_files(root: str, recursive: bool = True) -> list[str]:
|
|
|
141
141
|
A list of file paths.
|
|
142
142
|
"""
|
|
143
143
|
if not recursive:
|
|
144
|
-
return [path for path in glob.glob(str(Path(root)) + "
|
|
144
|
+
return [path for path in glob.glob(str(Path(root)) + "/**")]
|
|
145
145
|
paths = []
|
|
146
146
|
for root_dir, _, files in os.walk(root):
|
|
147
147
|
for file in files:
|
|
@@ -205,7 +205,7 @@ def unit_is_degrees(gdf: GeoDataFrame) -> bool:
|
|
|
205
205
|
|
|
206
206
|
def get_object_name(
|
|
207
207
|
var: object, start: int = 2, stop: int = 7, ignore_self: bool = True
|
|
208
|
-
) -> str
|
|
208
|
+
) -> str:
|
|
209
209
|
frame = inspect.currentframe() # frame can be FrameType or None
|
|
210
210
|
if frame:
|
|
211
211
|
try:
|
|
@@ -230,7 +230,7 @@ def get_object_name(
|
|
|
230
230
|
finally:
|
|
231
231
|
if frame:
|
|
232
232
|
del frame # Explicitly delete frame reference to assist with garbage collection
|
|
233
|
-
|
|
233
|
+
raise ValueError(f"Couldn't find name for {var}")
|
|
234
234
|
|
|
235
235
|
|
|
236
236
|
def make_namedict(gdfs: tuple[GeoDataFrame]) -> dict[int, str]:
|
|
@@ -15,7 +15,7 @@ def read_parquet_url(url: str) -> GeoDataFrame:
|
|
|
15
15
|
A GeoDataFrame.
|
|
16
16
|
|
|
17
17
|
Examples:
|
|
18
|
-
|
|
18
|
+
---------
|
|
19
19
|
>>> from sgis import read_parquet_url
|
|
20
20
|
>>> url = "https://media.githubusercontent.com/media/statisticsnorway/ssb-sgis/main/tests/testdata/points_oslo.parquet"
|
|
21
21
|
>>> points = read_parquet_url(url)
|
|
@@ -3,6 +3,10 @@ import numpy as np
|
|
|
3
3
|
|
|
4
4
|
from ..geopandas_tools.bounds import get_total_bounds
|
|
5
5
|
from ..helpers import unit_is_degrees
|
|
6
|
+
from ..raster.image_collection import Band
|
|
7
|
+
from ..raster.image_collection import Image
|
|
8
|
+
from ..raster.image_collection import ImageCollection
|
|
9
|
+
from .explore import Explore
|
|
6
10
|
from .map import Map
|
|
7
11
|
from .maps import clipmap
|
|
8
12
|
from .maps import explore
|
|
@@ -22,7 +26,7 @@ class Examine:
|
|
|
22
26
|
can then be repeated.
|
|
23
27
|
|
|
24
28
|
Examples:
|
|
25
|
-
|
|
29
|
+
---------
|
|
26
30
|
Create the examiner.
|
|
27
31
|
|
|
28
32
|
>>> import sgis as sg
|
|
@@ -93,11 +97,15 @@ class Examine:
|
|
|
93
97
|
else:
|
|
94
98
|
self.mask_gdf = mask_gdf
|
|
95
99
|
|
|
96
|
-
m =
|
|
100
|
+
m = Explore(*gdfs, column=column, **kwargs)
|
|
101
|
+
|
|
102
|
+
# m = Map(*gdfs, column=column, **kwargs)
|
|
97
103
|
self._gdfs: dict[str, gpd.GeoDataFrame] = dict(
|
|
98
104
|
zip(m.labels, m.gdfs, strict=False)
|
|
99
105
|
)
|
|
100
106
|
|
|
107
|
+
self.rasters: dict[str, ImageCollection | Image | Band] = m.rasters
|
|
108
|
+
|
|
101
109
|
self.indices = list(range(len(self.mask_gdf)))
|
|
102
110
|
self.i = 0
|
|
103
111
|
self.column = column
|
|
@@ -154,6 +162,7 @@ class Examine:
|
|
|
154
162
|
print(f"i == {self.i} (of {len(self.mask_gdf)})")
|
|
155
163
|
clipmap(
|
|
156
164
|
self.column,
|
|
165
|
+
*list(self.rasters.values()),
|
|
157
166
|
**self._gdfs,
|
|
158
167
|
mask=self.mask_gdf.iloc[[self.i]].buffer(self.size),
|
|
159
168
|
**self.kwargs,
|
|
@@ -175,6 +184,7 @@ class Examine:
|
|
|
175
184
|
print(f"Showing index {i}")
|
|
176
185
|
clipmap(
|
|
177
186
|
self.column,
|
|
187
|
+
*list(self.rasters.values()),
|
|
178
188
|
**self._gdfs,
|
|
179
189
|
mask=self.mask_gdf.iloc[[i]].buffer(self.size),
|
|
180
190
|
**self.kwargs,
|
|
@@ -194,6 +204,7 @@ class Examine:
|
|
|
194
204
|
print(f"{self.i + 1} of {len(self.mask_gdf)}")
|
|
195
205
|
clipmap(
|
|
196
206
|
self.column,
|
|
207
|
+
*list(self.rasters.values()),
|
|
197
208
|
**self._gdfs,
|
|
198
209
|
mask=self.mask_gdf.iloc[[self.i]].buffer(self.size),
|
|
199
210
|
**self.kwargs,
|
|
@@ -206,6 +217,7 @@ class Examine:
|
|
|
206
217
|
self.kwargs = self.kwargs | kwargs
|
|
207
218
|
|
|
208
219
|
explore(
|
|
220
|
+
*list(self.rasters.values()),
|
|
209
221
|
**self._gdfs,
|
|
210
222
|
column=self.column,
|
|
211
223
|
**self.kwargs,
|
|
@@ -218,6 +230,7 @@ class Examine:
|
|
|
218
230
|
self.kwargs = self.kwargs | kwargs
|
|
219
231
|
|
|
220
232
|
clipmap(
|
|
233
|
+
*list(self.rasters.values()),
|
|
221
234
|
**self._gdfs,
|
|
222
235
|
column=self.column,
|
|
223
236
|
**self.kwargs,
|
|
@@ -230,6 +243,7 @@ class Examine:
|
|
|
230
243
|
self.kwargs = self.kwargs | kwargs
|
|
231
244
|
|
|
232
245
|
samplemap(
|
|
246
|
+
*list(self.rasters.values()),
|
|
233
247
|
**self._gdfs,
|
|
234
248
|
column=self.column,
|
|
235
249
|
**self.kwargs,
|