ssb-sgis 1.0.1__py3-none-any.whl → 1.0.3__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 +107 -121
- sgis/exceptions.py +5 -3
- sgis/geopandas_tools/__init__.py +1 -0
- sgis/geopandas_tools/bounds.py +86 -47
- sgis/geopandas_tools/buffer_dissolve_explode.py +62 -39
- sgis/geopandas_tools/centerlines.py +53 -44
- sgis/geopandas_tools/cleaning.py +87 -104
- sgis/geopandas_tools/conversion.py +164 -107
- sgis/geopandas_tools/duplicates.py +33 -19
- sgis/geopandas_tools/general.py +84 -52
- sgis/geopandas_tools/geometry_types.py +24 -10
- sgis/geopandas_tools/neighbors.py +23 -11
- sgis/geopandas_tools/overlay.py +136 -53
- sgis/geopandas_tools/point_operations.py +11 -10
- sgis/geopandas_tools/polygon_operations.py +53 -61
- sgis/geopandas_tools/polygons_as_rings.py +121 -78
- sgis/geopandas_tools/sfilter.py +17 -17
- sgis/helpers.py +116 -58
- sgis/io/dapla_functions.py +32 -23
- sgis/io/opener.py +13 -6
- sgis/io/read_parquet.py +2 -2
- sgis/maps/examine.py +55 -28
- sgis/maps/explore.py +471 -112
- sgis/maps/httpserver.py +12 -12
- sgis/maps/legend.py +285 -134
- sgis/maps/map.py +248 -129
- sgis/maps/maps.py +123 -119
- sgis/maps/thematicmap.py +260 -94
- sgis/maps/tilesources.py +3 -8
- sgis/networkanalysis/_get_route.py +5 -4
- sgis/networkanalysis/_od_cost_matrix.py +44 -1
- sgis/networkanalysis/_points.py +10 -4
- sgis/networkanalysis/_service_area.py +5 -2
- sgis/networkanalysis/closing_network_holes.py +22 -64
- sgis/networkanalysis/cutting_lines.py +58 -46
- sgis/networkanalysis/directednetwork.py +16 -8
- sgis/networkanalysis/finding_isolated_networks.py +6 -5
- sgis/networkanalysis/network.py +15 -13
- sgis/networkanalysis/networkanalysis.py +79 -61
- sgis/networkanalysis/networkanalysisrules.py +21 -17
- sgis/networkanalysis/nodes.py +2 -3
- sgis/networkanalysis/traveling_salesman.py +6 -3
- sgis/parallel/parallel.py +372 -142
- sgis/raster/base.py +9 -3
- sgis/raster/cube.py +331 -213
- sgis/raster/cubebase.py +15 -29
- sgis/raster/image_collection.py +2560 -0
- sgis/raster/indices.py +17 -12
- sgis/raster/raster.py +356 -275
- sgis/raster/sentinel_config.py +104 -0
- sgis/raster/zonal.py +38 -14
- {ssb_sgis-1.0.1.dist-info → ssb_sgis-1.0.3.dist-info}/LICENSE +1 -1
- {ssb_sgis-1.0.1.dist-info → ssb_sgis-1.0.3.dist-info}/METADATA +87 -16
- ssb_sgis-1.0.3.dist-info/RECORD +61 -0
- {ssb_sgis-1.0.1.dist-info → ssb_sgis-1.0.3.dist-info}/WHEEL +1 -1
- sgis/raster/bands.py +0 -48
- sgis/raster/gradient.py +0 -78
- sgis/raster/methods_as_functions.py +0 -124
- sgis/raster/torchgeo.py +0 -150
- ssb_sgis-1.0.1.dist-info/RECORD +0 -63
sgis/raster/indices.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from
|
|
1
|
+
from collections.abc import Callable
|
|
2
2
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
import pandas as pd
|
|
@@ -7,7 +7,16 @@ from .raster import Raster
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
def ndvi(red: np.ndarray, nir: np.ndarray) -> np.ndarray:
|
|
10
|
-
|
|
10
|
+
# normalize red and nir arrays to 0-1 scale if needed
|
|
11
|
+
if red.max() > 1 and nir.max() > 1:
|
|
12
|
+
red = red / 255
|
|
13
|
+
nir = nir / 255
|
|
14
|
+
elif red.max() > 1 or nir.max() > 1:
|
|
15
|
+
raise ValueError()
|
|
16
|
+
|
|
17
|
+
ndvi_values = np.where((red + nir) == 0, 0, (nir - red) / (nir + red))
|
|
18
|
+
|
|
19
|
+
return ndvi_values
|
|
11
20
|
|
|
12
21
|
|
|
13
22
|
def gndvi(green: np.ndarray, nir: np.ndarray) -> np.ndarray:
|
|
@@ -18,10 +27,6 @@ def water(green: np.ndarray, nir: np.ndarray) -> np.ndarray:
|
|
|
18
27
|
return np.where((green + nir) == 0, 0, (green - nir) / (green + nir))
|
|
19
28
|
|
|
20
29
|
|
|
21
|
-
def water(swir: np.ndarray, nir: np.ndarray) -> np.ndarray:
|
|
22
|
-
return np.where((swir + nir) == 0, 0, (nir - swir) / (nir + swir))
|
|
23
|
-
|
|
24
|
-
|
|
25
30
|
def builtup(swir: np.ndarray, nir: np.ndarray) -> np.ndarray:
|
|
26
31
|
return np.where((swir + nir) == 0, 0, (swir - nir) / (swir + nir))
|
|
27
32
|
|
|
@@ -34,13 +39,13 @@ def get_raster_pairs(
|
|
|
34
39
|
cube,
|
|
35
40
|
band_name1: str,
|
|
36
41
|
band_name2: str,
|
|
37
|
-
):
|
|
42
|
+
) -> list[tuple[Raster, Raster]]:
|
|
38
43
|
unique = pd.DataFrame({"tile": cube.tile, "date": cube.date}).drop_duplicates(
|
|
39
44
|
["tile", "date"]
|
|
40
45
|
)
|
|
41
46
|
|
|
42
47
|
raster_pairs = []
|
|
43
|
-
for tile, date in zip(unique["tile"], unique["date"]):
|
|
48
|
+
for tile, date in zip(unique["tile"], unique["date"], strict=False):
|
|
44
49
|
query = (cube.tile == tile) & (cube.date == date)
|
|
45
50
|
band1 = cube.copy()[query & (cube.band == band_name1)]
|
|
46
51
|
band2 = cube.copy()[query & (cube.band == band_name2)]
|
|
@@ -74,13 +79,13 @@ def index_calc_pair(
|
|
|
74
79
|
assert isinstance(r1, Raster), r1
|
|
75
80
|
assert isinstance(r2, Raster), r2
|
|
76
81
|
|
|
77
|
-
if r1.
|
|
82
|
+
if r1.values is None:
|
|
78
83
|
r1 = r1.load()
|
|
79
|
-
if r2.
|
|
84
|
+
if r2.values is None:
|
|
80
85
|
r2 = r2.load()
|
|
81
86
|
|
|
82
|
-
r1_arr: np.ndarray = r1.
|
|
83
|
-
r2_arr: np.ndarray = r2.
|
|
87
|
+
r1_arr: np.ndarray = r1.values.astype(np.float16)
|
|
88
|
+
r2_arr: np.ndarray = r2.values.astype(np.float16)
|
|
84
89
|
|
|
85
90
|
out_array = index_formula(r1_arr, r2_arr)
|
|
86
91
|
|