yirgacheffe 1.7.9__py3-none-any.whl → 1.8.0__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.
Potentially problematic release.
This version of yirgacheffe might be problematic. Click here for more details.
- yirgacheffe/__init__.py +1 -0
- yirgacheffe/_backends/mlx.py +4 -2
- yirgacheffe/_backends/numpy.py +4 -2
- yirgacheffe/_core.py +76 -96
- yirgacheffe/_operators.py +25 -28
- yirgacheffe/layers/area.py +5 -3
- yirgacheffe/layers/base.py +20 -27
- yirgacheffe/layers/constant.py +4 -2
- yirgacheffe/layers/group.py +11 -11
- yirgacheffe/layers/h3layer.py +4 -2
- yirgacheffe/layers/rasters.py +18 -18
- yirgacheffe/layers/rescaled.py +3 -3
- yirgacheffe/layers/vectors.py +36 -37
- yirgacheffe/rounding.py +4 -3
- yirgacheffe/window.py +49 -96
- {yirgacheffe-1.7.9.dist-info → yirgacheffe-1.8.0.dist-info}/METADATA +8 -4
- yirgacheffe-1.8.0.dist-info/RECORD +27 -0
- yirgacheffe-1.7.9.dist-info/RECORD +0 -27
- {yirgacheffe-1.7.9.dist-info → yirgacheffe-1.8.0.dist-info}/WHEEL +0 -0
- {yirgacheffe-1.7.9.dist-info → yirgacheffe-1.8.0.dist-info}/entry_points.txt +0 -0
- {yirgacheffe-1.7.9.dist-info → yirgacheffe-1.8.0.dist-info}/licenses/LICENSE +0 -0
- {yirgacheffe-1.7.9.dist-info → yirgacheffe-1.8.0.dist-info}/top_level.txt +0 -0
yirgacheffe/layers/h3layer.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
from math import ceil, floor
|
|
2
|
-
from typing import Any
|
|
4
|
+
from typing import Any
|
|
3
5
|
|
|
4
6
|
import h3
|
|
5
7
|
import numpy as np
|
|
@@ -75,7 +77,7 @@ class H3CellLayer(YirgacheffeLayer):
|
|
|
75
77
|
)
|
|
76
78
|
|
|
77
79
|
@property
|
|
78
|
-
def _raster_dimensions(self) ->
|
|
80
|
+
def _raster_dimensions(self) -> tuple[int, int]:
|
|
79
81
|
return (self._raster_xsize, self._raster_ysize)
|
|
80
82
|
|
|
81
83
|
@property
|
yirgacheffe/layers/rasters.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
import math
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
from typing import Any
|
|
4
|
+
from typing import Any
|
|
5
5
|
|
|
6
6
|
import numpy as np
|
|
7
7
|
from osgeo import gdal
|
|
@@ -26,14 +26,14 @@ class RasterLayer(YirgacheffeLayer):
|
|
|
26
26
|
def empty_raster_layer(
|
|
27
27
|
area: Area,
|
|
28
28
|
scale: PixelScale,
|
|
29
|
-
datatype:
|
|
30
|
-
filename:
|
|
29
|
+
datatype: int | DataType,
|
|
30
|
+
filename: Path | str | None = None,
|
|
31
31
|
projection: str=WGS_84_PROJECTION,
|
|
32
|
-
name:
|
|
32
|
+
name: str | None = None,
|
|
33
33
|
compress: bool=True,
|
|
34
|
-
nodata:
|
|
35
|
-
nbits:
|
|
36
|
-
threads:
|
|
34
|
+
nodata: float | int | None = None,
|
|
35
|
+
nbits: int | None = None,
|
|
36
|
+
threads: int | None = None,
|
|
37
37
|
bands: int=1
|
|
38
38
|
) -> RasterLayer:
|
|
39
39
|
abs_xstep, abs_ystep = abs(scale.xstep), abs(scale.ystep)
|
|
@@ -88,13 +88,13 @@ class RasterLayer(YirgacheffeLayer):
|
|
|
88
88
|
@staticmethod
|
|
89
89
|
def empty_raster_layer_like(
|
|
90
90
|
layer: Any,
|
|
91
|
-
filename:
|
|
92
|
-
area:
|
|
93
|
-
datatype:
|
|
91
|
+
filename: Path | str | None = None,
|
|
92
|
+
area: Area | None = None,
|
|
93
|
+
datatype: int | DataType | None = None,
|
|
94
94
|
compress: bool=True,
|
|
95
|
-
nodata:
|
|
96
|
-
nbits:
|
|
97
|
-
threads:
|
|
95
|
+
nodata: float | int | None = None,
|
|
96
|
+
nbits: int | None = None,
|
|
97
|
+
threads: int | None = None,
|
|
98
98
|
bands: int=1
|
|
99
99
|
) -> RasterLayer:
|
|
100
100
|
if area is None:
|
|
@@ -165,7 +165,7 @@ class RasterLayer(YirgacheffeLayer):
|
|
|
165
165
|
cls,
|
|
166
166
|
source: RasterLayer,
|
|
167
167
|
new_pixel_scale: PixelScale,
|
|
168
|
-
filename:
|
|
168
|
+
filename: Path | str | None = None,
|
|
169
169
|
compress: bool=True,
|
|
170
170
|
algorithm: int=gdal.GRA_NearestNeighbour,
|
|
171
171
|
) -> RasterLayer:
|
|
@@ -220,7 +220,7 @@ class RasterLayer(YirgacheffeLayer):
|
|
|
220
220
|
@classmethod
|
|
221
221
|
def layer_from_file(
|
|
222
222
|
cls,
|
|
223
|
-
filename:
|
|
223
|
+
filename: Path | str,
|
|
224
224
|
band: int = 1,
|
|
225
225
|
ignore_nodata: bool = False,
|
|
226
226
|
) -> RasterLayer:
|
|
@@ -238,7 +238,7 @@ class RasterLayer(YirgacheffeLayer):
|
|
|
238
238
|
def __init__(
|
|
239
239
|
self,
|
|
240
240
|
dataset: gdal.Dataset,
|
|
241
|
-
name:
|
|
241
|
+
name: str | None = None,
|
|
242
242
|
band: int = 1,
|
|
243
243
|
ignore_nodata: bool = False,
|
|
244
244
|
) -> None:
|
|
@@ -273,7 +273,7 @@ class RasterLayer(YirgacheffeLayer):
|
|
|
273
273
|
self._ignore_nodata = ignore_nodata
|
|
274
274
|
|
|
275
275
|
@property
|
|
276
|
-
def _raster_dimensions(self) ->
|
|
276
|
+
def _raster_dimensions(self) -> tuple[int, int]:
|
|
277
277
|
return (self._raster_xsize, self._raster_ysize)
|
|
278
278
|
|
|
279
279
|
def close(self):
|
|
@@ -321,7 +321,7 @@ class RasterLayer(YirgacheffeLayer):
|
|
|
321
321
|
return DataType.of_gdal(self._dataset.GetRasterBand(1).DataType)
|
|
322
322
|
|
|
323
323
|
@property
|
|
324
|
-
def nodata(self) ->
|
|
324
|
+
def nodata(self) -> Any | None:
|
|
325
325
|
if self._dataset is None:
|
|
326
326
|
self._unpark()
|
|
327
327
|
assert self._dataset
|
yirgacheffe/layers/rescaled.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from math import floor, ceil
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
from typing import Any
|
|
4
|
+
from typing import Any
|
|
5
5
|
|
|
6
6
|
from skimage import transform
|
|
7
7
|
|
|
@@ -18,7 +18,7 @@ class RescaledRasterLayer(YirgacheffeLayer):
|
|
|
18
18
|
@classmethod
|
|
19
19
|
def layer_from_file(
|
|
20
20
|
cls,
|
|
21
|
-
filename:
|
|
21
|
+
filename: Path | str,
|
|
22
22
|
pixel_scale: PixelScale,
|
|
23
23
|
band: int = 1,
|
|
24
24
|
nearest_neighbour: bool = True,
|
|
@@ -35,7 +35,7 @@ class RescaledRasterLayer(YirgacheffeLayer):
|
|
|
35
35
|
src: RasterLayer,
|
|
36
36
|
target_projection: MapProjection,
|
|
37
37
|
nearest_neighbour: bool = True,
|
|
38
|
-
name:
|
|
38
|
+
name: str | None = None,
|
|
39
39
|
):
|
|
40
40
|
super().__init__(
|
|
41
41
|
src.area,
|
yirgacheffe/layers/vectors.py
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
from math import ceil, floor
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
from typing import Any
|
|
5
|
-
from typing_extensions import NotRequired
|
|
4
|
+
from typing import Any
|
|
6
5
|
|
|
7
6
|
import deprecation
|
|
8
7
|
from osgeo import gdal, ogr
|
|
@@ -70,12 +69,12 @@ class RasteredVectorLayer(RasterLayer):
|
|
|
70
69
|
)
|
|
71
70
|
def layer_from_file( # type: ignore[override] # pylint: disable=W0221
|
|
72
71
|
cls,
|
|
73
|
-
filename:
|
|
74
|
-
where_filter:
|
|
72
|
+
filename: Path | str,
|
|
73
|
+
where_filter: str | None,
|
|
75
74
|
scale: PixelScale,
|
|
76
75
|
projection: str,
|
|
77
|
-
datatype:
|
|
78
|
-
burn_value:
|
|
76
|
+
datatype: int | DataType | None = None,
|
|
77
|
+
burn_value: int | float | str = 1,
|
|
79
78
|
) -> RasteredVectorLayer:
|
|
80
79
|
vectors = ogr.Open(filename)
|
|
81
80
|
if vectors is None:
|
|
@@ -111,14 +110,14 @@ class RasteredVectorLayer(RasterLayer):
|
|
|
111
110
|
self,
|
|
112
111
|
layer: ogr.Layer,
|
|
113
112
|
projection: MapProjection,
|
|
114
|
-
datatype:
|
|
115
|
-
burn_value:
|
|
113
|
+
datatype: int | DataType = DataType.Byte,
|
|
114
|
+
burn_value: int | float | str = 1,
|
|
116
115
|
):
|
|
117
116
|
if layer is None:
|
|
118
117
|
raise ValueError('No layer provided')
|
|
119
118
|
self.layer = layer
|
|
120
119
|
|
|
121
|
-
self._original:
|
|
120
|
+
self._original: Any | None = None
|
|
122
121
|
|
|
123
122
|
if isinstance(datatype, int):
|
|
124
123
|
datatype_arg = DataType.of_gdal(datatype)
|
|
@@ -180,11 +179,11 @@ class VectorLayer(YirgacheffeLayer):
|
|
|
180
179
|
@classmethod
|
|
181
180
|
def layer_from_file_like(
|
|
182
181
|
cls,
|
|
183
|
-
filename:
|
|
182
|
+
filename: Path | str,
|
|
184
183
|
other_layer: YirgacheffeLayer,
|
|
185
|
-
where_filter:
|
|
186
|
-
datatype:
|
|
187
|
-
burn_value:
|
|
184
|
+
where_filter: str | None = None,
|
|
185
|
+
datatype: int | DataType | None = None,
|
|
186
|
+
burn_value: int | float | str = 1,
|
|
188
187
|
) -> VectorLayer:
|
|
189
188
|
if other_layer is None:
|
|
190
189
|
raise ValueError("like layer can not be None")
|
|
@@ -223,13 +222,13 @@ class VectorLayer(YirgacheffeLayer):
|
|
|
223
222
|
@classmethod
|
|
224
223
|
def layer_from_file(
|
|
225
224
|
cls,
|
|
226
|
-
filename:
|
|
227
|
-
where_filter:
|
|
228
|
-
scale:
|
|
229
|
-
projection:
|
|
230
|
-
datatype:
|
|
231
|
-
burn_value:
|
|
232
|
-
anchor:
|
|
225
|
+
filename: Path | str,
|
|
226
|
+
where_filter: str | None,
|
|
227
|
+
scale: PixelScale | None,
|
|
228
|
+
projection: str | None,
|
|
229
|
+
datatype: int | DataType | None = None,
|
|
230
|
+
burn_value: int | float | str = 1,
|
|
231
|
+
anchor: tuple[float, float] = (0.0, 0.0)
|
|
233
232
|
) -> VectorLayer:
|
|
234
233
|
# In 2.0 we need to remove this and migrate to the MapProjection version
|
|
235
234
|
if (projection is None) ^ (scale is None):
|
|
@@ -250,12 +249,12 @@ class VectorLayer(YirgacheffeLayer):
|
|
|
250
249
|
@classmethod
|
|
251
250
|
def _future_layer_from_file(
|
|
252
251
|
cls,
|
|
253
|
-
filename:
|
|
254
|
-
where_filter:
|
|
255
|
-
projection:
|
|
256
|
-
datatype:
|
|
257
|
-
burn_value:
|
|
258
|
-
anchor:
|
|
252
|
+
filename: Path | str,
|
|
253
|
+
where_filter: str | None,
|
|
254
|
+
projection: MapProjection | None,
|
|
255
|
+
datatype: int | DataType | None = None,
|
|
256
|
+
burn_value: int | float | str = 1,
|
|
257
|
+
anchor: tuple[float, float] = (0.0, 0.0)
|
|
259
258
|
) -> VectorLayer:
|
|
260
259
|
try:
|
|
261
260
|
vectors = ogr.Open(filename)
|
|
@@ -295,11 +294,11 @@ class VectorLayer(YirgacheffeLayer):
|
|
|
295
294
|
def __init__(
|
|
296
295
|
self,
|
|
297
296
|
layer: ogr.Layer,
|
|
298
|
-
projection:
|
|
299
|
-
name:
|
|
300
|
-
datatype:
|
|
301
|
-
burn_value:
|
|
302
|
-
anchor:
|
|
297
|
+
projection: MapProjection | None,
|
|
298
|
+
name: str | None = None,
|
|
299
|
+
datatype: int | DataType = DataType.Byte,
|
|
300
|
+
burn_value: int | float | str = 1,
|
|
301
|
+
anchor: tuple[float, float] = (0.0, 0.0)
|
|
303
302
|
):
|
|
304
303
|
if layer is None:
|
|
305
304
|
raise ValueError('No layer provided')
|
|
@@ -316,9 +315,9 @@ class VectorLayer(YirgacheffeLayer):
|
|
|
316
315
|
self.burn_value = burn_value
|
|
317
316
|
|
|
318
317
|
self._original = None
|
|
319
|
-
self._dataset_path:
|
|
320
|
-
self._filter:
|
|
321
|
-
self._anchor:
|
|
318
|
+
self._dataset_path: Path | None = None
|
|
319
|
+
self._filter: str | None = None
|
|
320
|
+
self._anchor: tuple[float, float] = (0.0, 0.0)
|
|
322
321
|
|
|
323
322
|
# work out region for mask
|
|
324
323
|
envelopes = []
|
|
@@ -368,7 +367,7 @@ class VectorLayer(YirgacheffeLayer):
|
|
|
368
367
|
super().__init__(area, projection)
|
|
369
368
|
|
|
370
369
|
|
|
371
|
-
def _get_operation_area(self, projection:
|
|
370
|
+
def _get_operation_area(self, projection: MapProjection | None = None) -> Area:
|
|
372
371
|
if self._projection is not None and projection is not None and self._projection != projection:
|
|
373
372
|
raise ValueError("Calculation projection does not match layer projection")
|
|
374
373
|
|
|
@@ -449,7 +448,7 @@ class VectorLayer(YirgacheffeLayer):
|
|
|
449
448
|
def _read_array_for_area(
|
|
450
449
|
self,
|
|
451
450
|
target_area: Area,
|
|
452
|
-
target_projection:
|
|
451
|
+
target_projection: MapProjection | None,
|
|
453
452
|
x: int,
|
|
454
453
|
y: int,
|
|
455
454
|
width: int,
|
|
@@ -496,7 +495,7 @@ class VectorLayer(YirgacheffeLayer):
|
|
|
496
495
|
return res
|
|
497
496
|
|
|
498
497
|
def _read_array_with_window(self, _x, _y, _width, _height, _window) -> Any:
|
|
499
|
-
|
|
498
|
+
raise NotImplementedError("VectorLayer does not support windowed reading")
|
|
500
499
|
|
|
501
500
|
def _read_array(self, x: int, y: int, width: int, height: int) -> Any:
|
|
502
501
|
return self._read_array_for_area(self.area, None, x, y, width, height)
|
yirgacheffe/rounding.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import math
|
|
2
4
|
import sys
|
|
3
|
-
from typing import List, Optional
|
|
4
5
|
|
|
5
6
|
from .window import PixelScale
|
|
6
7
|
|
|
@@ -39,10 +40,10 @@ def round_down_pixels(value: float, pixelscale: float) -> int:
|
|
|
39
40
|
else:
|
|
40
41
|
return math.floor(value)
|
|
41
42
|
|
|
42
|
-
def are_pixel_scales_equal_enough(pixel_scales:
|
|
43
|
+
def are_pixel_scales_equal_enough(pixel_scales: list[PixelScale | None]) -> bool:
|
|
43
44
|
# some layers (e.g., constant layers) have no scale, and always work, so filter
|
|
44
45
|
# them out first
|
|
45
|
-
cleaned_pixel_scales:
|
|
46
|
+
cleaned_pixel_scales: list[PixelScale] = [x for x in pixel_scales if x is not None]
|
|
46
47
|
|
|
47
48
|
try:
|
|
48
49
|
first = cleaned_pixel_scales[0]
|
yirgacheffe/window.py
CHANGED
|
@@ -3,7 +3,6 @@ import math
|
|
|
3
3
|
import sys
|
|
4
4
|
from collections import namedtuple
|
|
5
5
|
from dataclasses import dataclass
|
|
6
|
-
from typing import List, Optional, Tuple
|
|
7
6
|
|
|
8
7
|
PixelScale = namedtuple('PixelScale', ['xstep', 'ystep'])
|
|
9
8
|
|
|
@@ -13,23 +12,15 @@ class MapProjection:
|
|
|
13
12
|
|
|
14
13
|
This superceeeds the old PixelScale class, which will be removed in version 2.0.
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
The map projection
|
|
20
|
-
xstep : float
|
|
21
|
-
The number of units horizontal distance a step of one pixel makes in the map projection.
|
|
22
|
-
ystep : float
|
|
23
|
-
The number of units verticle distance a step of one pixel makes in the map projection.
|
|
15
|
+
Args:
|
|
16
|
+
name: The map projection used.
|
|
17
|
+
xstep: The number of units horizontal distance a step of one pixel makes in the map projection.
|
|
18
|
+
ystep: The number of units vertical distance a step of one pixel makes in the map projection.
|
|
24
19
|
|
|
25
|
-
Attributes
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
The map projection
|
|
29
|
-
xstep : float
|
|
30
|
-
The number of units horizontal distance a step of one pixel makes in the map projection.
|
|
31
|
-
ystep : float
|
|
32
|
-
The number of units verticle distance a step of one pixel makes in the map projection.
|
|
20
|
+
Attributes:
|
|
21
|
+
name: The map projection used.
|
|
22
|
+
xstep: The number of units horizontal distance a step of one pixel makes in the map projection.
|
|
23
|
+
ystep: The number of units vertical distance a step of one pixel makes in the map projection.
|
|
33
24
|
"""
|
|
34
25
|
|
|
35
26
|
name : str
|
|
@@ -52,27 +43,17 @@ class MapProjection:
|
|
|
52
43
|
class Area:
|
|
53
44
|
"""Class to hold a geospatial area of data in the given projection.
|
|
54
45
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
Attributes
|
|
67
|
-
----------
|
|
68
|
-
left : float
|
|
69
|
-
Left most point in the projection space
|
|
70
|
-
top : float
|
|
71
|
-
Top most point in the projection space
|
|
72
|
-
right : float
|
|
73
|
-
Right most point in the projection space
|
|
74
|
-
bottom : float
|
|
75
|
-
Bottom most point in the projection space
|
|
46
|
+
Args:
|
|
47
|
+
left: Left most point in the projection space.
|
|
48
|
+
top: Top most point in the projection space.
|
|
49
|
+
right: Right most point in the projection space.
|
|
50
|
+
bottom: Bottom most point in the projection space.
|
|
51
|
+
|
|
52
|
+
Attributes:
|
|
53
|
+
left: Left most point in the projection space.
|
|
54
|
+
top: Top most point in the projection space.
|
|
55
|
+
right: Right most point in the projection space.
|
|
56
|
+
bottom: Bottom most point in the projection space.
|
|
76
57
|
"""
|
|
77
58
|
left: float
|
|
78
59
|
top: float
|
|
@@ -83,9 +64,7 @@ class Area:
|
|
|
83
64
|
def world() -> Area:
|
|
84
65
|
"""Creates an area that covers the entire planet.
|
|
85
66
|
|
|
86
|
-
Returns
|
|
87
|
-
-------
|
|
88
|
-
Area
|
|
67
|
+
Returns:
|
|
89
68
|
An area where the extents are nan, but is_world returns true.
|
|
90
69
|
"""
|
|
91
70
|
return Area(float("nan"), float("nan"), float("nan"), float("nan"))
|
|
@@ -99,21 +78,16 @@ class Area:
|
|
|
99
78
|
math.isclose(self.top, other.top, abs_tol=1e-09) and \
|
|
100
79
|
math.isclose(self.bottom, other.bottom, abs_tol=1e-09)
|
|
101
80
|
|
|
102
|
-
def grow(self, offset: float):
|
|
81
|
+
def grow(self, offset: float) -> Area:
|
|
103
82
|
"""Expand the area in all directions by the given amount.
|
|
104
83
|
|
|
105
84
|
Generates a new area that is an expanded version of the current area.
|
|
106
85
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
offset : float
|
|
110
|
-
The amount by which to grow the area
|
|
86
|
+
Args:
|
|
87
|
+
offset: The amount by which to grow the area.
|
|
111
88
|
|
|
112
|
-
Returns
|
|
113
|
-
-------
|
|
114
|
-
Area
|
|
89
|
+
Returns:
|
|
115
90
|
A new area of the expanded size.
|
|
116
|
-
|
|
117
91
|
"""
|
|
118
92
|
return Area(
|
|
119
93
|
left=self.left - offset,
|
|
@@ -124,26 +98,20 @@ class Area:
|
|
|
124
98
|
|
|
125
99
|
@property
|
|
126
100
|
def is_world(self) -> bool:
|
|
127
|
-
"""Returns true if this is a global area,
|
|
101
|
+
"""Returns true if this is a global area, independent of projection.
|
|
128
102
|
|
|
129
|
-
Returns
|
|
130
|
-
|
|
131
|
-
bool
|
|
132
|
-
True is the Area was created with `world` otherwise False.
|
|
103
|
+
Returns:
|
|
104
|
+
True if the Area was created with `world` otherwise False.
|
|
133
105
|
"""
|
|
134
106
|
return math.isnan(self.left)
|
|
135
107
|
|
|
136
|
-
def overlaps(self, other) -> bool:
|
|
108
|
+
def overlaps(self, other: Area) -> bool:
|
|
137
109
|
"""Check if this area overlaps with another area.
|
|
138
110
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
other : Area
|
|
142
|
-
The other area to compare this area with
|
|
111
|
+
Args:
|
|
112
|
+
other: The other area to compare this area with.
|
|
143
113
|
|
|
144
|
-
Returns
|
|
145
|
-
-------
|
|
146
|
-
bool
|
|
114
|
+
Returns:
|
|
147
115
|
True if the two areas intersect, otherwise false.
|
|
148
116
|
"""
|
|
149
117
|
|
|
@@ -166,27 +134,17 @@ class Area:
|
|
|
166
134
|
class Window:
|
|
167
135
|
"""Class to hold the pixel dimensions of data in the given projection.
|
|
168
136
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
Attributes
|
|
181
|
-
----------
|
|
182
|
-
xoff : int
|
|
183
|
-
X axis offset
|
|
184
|
-
yoff : int
|
|
185
|
-
Y axis offset
|
|
186
|
-
xsize : int
|
|
187
|
-
Width of data in pixels
|
|
188
|
-
ysize : float
|
|
189
|
-
Height of data in pixels
|
|
137
|
+
Args:
|
|
138
|
+
xoff: X axis offset.
|
|
139
|
+
yoff: Y axis offset.
|
|
140
|
+
xsize: Width of data in pixels.
|
|
141
|
+
ysize: Height of data in pixels.
|
|
142
|
+
|
|
143
|
+
Attributes:
|
|
144
|
+
xoff: X axis offset.
|
|
145
|
+
yoff: Y axis offset.
|
|
146
|
+
xsize: Width of data in pixels.
|
|
147
|
+
ysize: Height of data in pixels.
|
|
190
148
|
"""
|
|
191
149
|
xoff: int
|
|
192
150
|
yoff: int
|
|
@@ -194,7 +152,7 @@ class Window:
|
|
|
194
152
|
ysize: int
|
|
195
153
|
|
|
196
154
|
@property
|
|
197
|
-
def as_array_args(self) ->
|
|
155
|
+
def as_array_args(self) -> tuple[int, ...]:
|
|
198
156
|
"""A tuple containing xoff, yoff, xsize, and ysize."""
|
|
199
157
|
return (self.xoff, self.yoff, self.xsize, self.ysize)
|
|
200
158
|
|
|
@@ -230,21 +188,16 @@ class Window:
|
|
|
230
188
|
((self.xoff + self.xsize) >= (other.xoff + other.xsize)) and \
|
|
231
189
|
((self.yoff + self.ysize) >= (other.yoff + other.ysize))
|
|
232
190
|
|
|
233
|
-
def grow(self, pixels: int):
|
|
191
|
+
def grow(self, pixels: int) -> Window:
|
|
234
192
|
"""Expand the area in all directions by the given amount.
|
|
235
193
|
|
|
236
194
|
Generates a new window that is an expanded version of the current window.
|
|
237
195
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
pixels : int
|
|
241
|
-
The amount by which to grow the window in pixels
|
|
196
|
+
Args:
|
|
197
|
+
pixels: The amount by which to grow the window in pixels.
|
|
242
198
|
|
|
243
|
-
Returns
|
|
244
|
-
-------
|
|
245
|
-
Window
|
|
199
|
+
Returns:
|
|
246
200
|
A new window of the expanded size.
|
|
247
|
-
|
|
248
201
|
"""
|
|
249
202
|
return Window(
|
|
250
203
|
xoff=self.xoff - pixels,
|
|
@@ -254,7 +207,7 @@ class Window:
|
|
|
254
207
|
)
|
|
255
208
|
|
|
256
209
|
@staticmethod
|
|
257
|
-
def find_intersection(windows:
|
|
210
|
+
def find_intersection(windows: list) -> Window:
|
|
258
211
|
if not windows:
|
|
259
212
|
raise ValueError("Expected list of windows")
|
|
260
213
|
# This isn't very pythonic, as it was originally written, but
|
|
@@ -277,7 +230,7 @@ class Window:
|
|
|
277
230
|
)
|
|
278
231
|
|
|
279
232
|
@staticmethod
|
|
280
|
-
def find_intersection_no_throw(windows:
|
|
233
|
+
def find_intersection_no_throw(windows: list) -> Window | None:
|
|
281
234
|
if not windows:
|
|
282
235
|
raise ValueError("Expected list of windows")
|
|
283
236
|
# This isn't very pythonic, as it was originally written, but
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: yirgacheffe
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.8.0
|
|
4
4
|
Summary: Abstraction of gdal datasets for doing basic math operations
|
|
5
5
|
Author-email: Michael Dales <mwd24@cam.ac.uk>
|
|
6
6
|
License-Expression: ISC
|
|
7
|
-
Project-URL: Homepage, https://
|
|
7
|
+
Project-URL: Homepage, https://yirgacheffe.org/
|
|
8
8
|
Project-URL: Repository, https://github.com/quantifyearth/yirgacheffe.git
|
|
9
9
|
Project-URL: Issues, https://github.com/quantifyearth/yirgacheffe/issues
|
|
10
|
-
Project-URL: Changelog, https://
|
|
10
|
+
Project-URL: Changelog, https://yirgacheffe.org/latest/changelog/
|
|
11
11
|
Keywords: gdal,gis,geospatial,declarative
|
|
12
12
|
Classifier: Development Status :: 5 - Production/Stable
|
|
13
13
|
Classifier: Intended Audience :: Science/Research
|
|
@@ -36,9 +36,13 @@ Requires-Dist: pytest; extra == "dev"
|
|
|
36
36
|
Requires-Dist: pytest-cov; extra == "dev"
|
|
37
37
|
Requires-Dist: build; extra == "dev"
|
|
38
38
|
Requires-Dist: twine; extra == "dev"
|
|
39
|
+
Requires-Dist: mkdocs-material; extra == "dev"
|
|
40
|
+
Requires-Dist: mkdocstrings-python; extra == "dev"
|
|
41
|
+
Requires-Dist: mike; extra == "dev"
|
|
42
|
+
Requires-Dist: mkdocs-gen-files; extra == "dev"
|
|
39
43
|
Dynamic: license-file
|
|
40
44
|
|
|
41
|
-
# Yirgacheffe: a
|
|
45
|
+
# Yirgacheffe: a declarative geospatial library for Python to make data-science with maps easier
|
|
42
46
|
|
|
43
47
|
## Overview
|
|
44
48
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
yirgacheffe/__init__.py,sha256=SBRDdk_GEIN6tOxxGrNySjT9ympv9FL6thEgsiycODo,615
|
|
2
|
+
yirgacheffe/_core.py,sha256=AU6tlqovBV_l1dNZs6AlHSw59Z0U6pStUaQZvJGiLhM,5721
|
|
3
|
+
yirgacheffe/_operators.py,sha256=OiR4pCVILmdXDmG37YILJuYjcxZlRussrJC7DeyoOts,36070
|
|
4
|
+
yirgacheffe/constants.py,sha256=uCWJwec3-ND-zVxYbsk1sdHKANl3ToNCTPg7MZb0j2g,434
|
|
5
|
+
yirgacheffe/operators.py,sha256=nw-BpnAwTjCwFtjosa8wKd2MGUuC0PJR5jACFdLhqCg,412
|
|
6
|
+
yirgacheffe/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
yirgacheffe/rounding.py,sha256=ZNuAaxsWfzYETC_G9H5weY1ZOci2pihEKTVrUiIqfZw,2257
|
|
8
|
+
yirgacheffe/window.py,sha256=-5eB3rnVUr7p_A2VKt_DqR-ACDeNwRt6X0_UEiVLCo8,8913
|
|
9
|
+
yirgacheffe/_backends/__init__.py,sha256=jN-2iRrHStnPI6cNL7XhwhsROtI0EaGfIrbF5c-ECV0,334
|
|
10
|
+
yirgacheffe/_backends/enumeration.py,sha256=Jrce2p2n4Wlk5tHBkiWntDnpLSD_0H-bnwgsKXHjkwQ,1018
|
|
11
|
+
yirgacheffe/_backends/mlx.py,sha256=U1gl1lK1mZXLEET6ylF1TNs6WJ0PBEvfSk7ppn28n8w,6203
|
|
12
|
+
yirgacheffe/_backends/numpy.py,sha256=Gxx49JJH79GFEkKIpV6IyjCUcdtN5-qLlzRfylzKhS4,4142
|
|
13
|
+
yirgacheffe/layers/__init__.py,sha256=mYKjw5YTcMNv_hMy7a6K4yRzIuNUbR8WuBTw4WIAmSk,435
|
|
14
|
+
yirgacheffe/layers/area.py,sha256=wJcMHbLJBaXS4BeFbu5rYeKfgu3gvaE9hwQ5j6aw-y4,3976
|
|
15
|
+
yirgacheffe/layers/base.py,sha256=dQQLFKP05QK4C73N1DCDYT8D8eD15HuSQKN5KrABeHg,14289
|
|
16
|
+
yirgacheffe/layers/constant.py,sha256=gtkQ98Z01CYYDgFElswtRZY4ZG3UnS5NIAoIVue5ufk,1481
|
|
17
|
+
yirgacheffe/layers/group.py,sha256=yaqf-ra_Vh59yrWcz7-OvJ1fBnTcBXZd18AfRDN5Ymo,16157
|
|
18
|
+
yirgacheffe/layers/h3layer.py,sha256=Rq1bFo7CApIh5NdBcV7hSj3hm-DszY79nhYsTRAvJ_g,9916
|
|
19
|
+
yirgacheffe/layers/rasters.py,sha256=zBE9uXm6LvAQF2_XdQzcOgJQOQWGmuPflY5JNDrUf3k,13527
|
|
20
|
+
yirgacheffe/layers/rescaled.py,sha256=gEFbXeYxX1nVn7eQYmbGww90_yc5ENmgQrD_WxXxpQE,3352
|
|
21
|
+
yirgacheffe/layers/vectors.py,sha256=AD1KcXO5acFZ9CTRENTPA_D9DMGSjAxGIF298LdeNeY,20010
|
|
22
|
+
yirgacheffe-1.8.0.dist-info/licenses/LICENSE,sha256=dNSHwUCJr6axStTKDEdnJtfmDdFqlE3h1NPCveqPfnY,757
|
|
23
|
+
yirgacheffe-1.8.0.dist-info/METADATA,sha256=wcJXfOQ15YfLkT-0TvivPXKZnyanK2wEQsalRY6f2Yk,23797
|
|
24
|
+
yirgacheffe-1.8.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
25
|
+
yirgacheffe-1.8.0.dist-info/entry_points.txt,sha256=j4KgHXbVGbGyfTySc1ypBdERpfihO4WNjppvCdE9HjE,52
|
|
26
|
+
yirgacheffe-1.8.0.dist-info/top_level.txt,sha256=9DBFlKO2Ld3hG6TuE3qOTd3Tt8ugTiXil4AN4Wr9_y0,12
|
|
27
|
+
yirgacheffe-1.8.0.dist-info/RECORD,,
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
yirgacheffe/__init__.py,sha256=pY9dqmHHARfY44T-7-7y6Ah97qQHj9_0pgYTItI5TR8,567
|
|
2
|
-
yirgacheffe/_core.py,sha256=hnACrthBI8OFNoi88-Qnj-4aizBGZstFO7kj-5g9MSU,6083
|
|
3
|
-
yirgacheffe/_operators.py,sha256=63KZZKTW-Pz0eOBRZUuolWxNNQvPC_sHruAdyo6J5dc,36238
|
|
4
|
-
yirgacheffe/constants.py,sha256=uCWJwec3-ND-zVxYbsk1sdHKANl3ToNCTPg7MZb0j2g,434
|
|
5
|
-
yirgacheffe/operators.py,sha256=nw-BpnAwTjCwFtjosa8wKd2MGUuC0PJR5jACFdLhqCg,412
|
|
6
|
-
yirgacheffe/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
yirgacheffe/rounding.py,sha256=ggBG4lMyLMtHLW3dBxr3gBCcF2qhRrY5etZiFGlIoqA,2258
|
|
8
|
-
yirgacheffe/window.py,sha256=Oxf8VcslLxNacqjUcDHqZLvdMaTnIwuNwjsm1WEOc0g,9503
|
|
9
|
-
yirgacheffe/_backends/__init__.py,sha256=jN-2iRrHStnPI6cNL7XhwhsROtI0EaGfIrbF5c-ECV0,334
|
|
10
|
-
yirgacheffe/_backends/enumeration.py,sha256=Jrce2p2n4Wlk5tHBkiWntDnpLSD_0H-bnwgsKXHjkwQ,1018
|
|
11
|
-
yirgacheffe/_backends/mlx.py,sha256=6a0S80JCxwiq72hWv-83238NaQykn-vQw_IDRBIBbbw,6173
|
|
12
|
-
yirgacheffe/_backends/numpy.py,sha256=N-Ygpw1lgJJI7xGoRJnB480rR0tst75cOIowubGnSjw,4112
|
|
13
|
-
yirgacheffe/layers/__init__.py,sha256=mYKjw5YTcMNv_hMy7a6K4yRzIuNUbR8WuBTw4WIAmSk,435
|
|
14
|
-
yirgacheffe/layers/area.py,sha256=LeLSinB-z2k4ODSfiNJvQnSnMfa8Gn7VnkJrLt50zVU,3970
|
|
15
|
-
yirgacheffe/layers/base.py,sha256=-7QIfAI3iGlzt-dDLztpRaLrL2sSqB1y2Yw2TdJ9VJM,14426
|
|
16
|
-
yirgacheffe/layers/constant.py,sha256=8wfyw1JOxr5FQv_M9Jzbd6vW2rjK3AJHmoe-ftDmPlM,1457
|
|
17
|
-
yirgacheffe/layers/group.py,sha256=hK84oCAweaX2eQP0DXPd_uHj1aVdTD9F-gaCRPfjxmY,16202
|
|
18
|
-
yirgacheffe/layers/h3layer.py,sha256=t8yC3c8pXU5qbFqsfP76ZX8UHkW9lK4ZgnNm4pwTjls,9886
|
|
19
|
-
yirgacheffe/layers/rasters.py,sha256=M2DG5-UPbhKsCHL5B2LDncqgb7VP6yzeDfXv_U6EaZo,13610
|
|
20
|
-
yirgacheffe/layers/rescaled.py,sha256=jbr2GxFy3I29vudX0oyMaFRTimrbEcAPI6dnHvjWpfU,3377
|
|
21
|
-
yirgacheffe/layers/vectors.py,sha256=c8QWeKF1umBGo5BYyJPl-CN_EfjxdTGNaQJDfAkvTIM,20139
|
|
22
|
-
yirgacheffe-1.7.9.dist-info/licenses/LICENSE,sha256=dNSHwUCJr6axStTKDEdnJtfmDdFqlE3h1NPCveqPfnY,757
|
|
23
|
-
yirgacheffe-1.7.9.dist-info/METADATA,sha256=cfrQwtndmOW5MTb28UoWG73U-1j4ufa1SyqoLACr2SA,23618
|
|
24
|
-
yirgacheffe-1.7.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
25
|
-
yirgacheffe-1.7.9.dist-info/entry_points.txt,sha256=j4KgHXbVGbGyfTySc1ypBdERpfihO4WNjppvCdE9HjE,52
|
|
26
|
-
yirgacheffe-1.7.9.dist-info/top_level.txt,sha256=9DBFlKO2Ld3hG6TuE3qOTd3Tt8ugTiXil4AN4Wr9_y0,12
|
|
27
|
-
yirgacheffe-1.7.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|