yirgacheffe 1.7.0__py3-none-any.whl → 1.7.2__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/_core.py +2 -2
- yirgacheffe/layers/base.py +6 -1
- yirgacheffe/layers/group.py +8 -8
- yirgacheffe/layers/vectors.py +5 -1
- yirgacheffe/operators.py +8 -4
- {yirgacheffe-1.7.0.dist-info → yirgacheffe-1.7.2.dist-info}/METADATA +1 -1
- {yirgacheffe-1.7.0.dist-info → yirgacheffe-1.7.2.dist-info}/RECORD +11 -11
- {yirgacheffe-1.7.0.dist-info → yirgacheffe-1.7.2.dist-info}/WHEEL +0 -0
- {yirgacheffe-1.7.0.dist-info → yirgacheffe-1.7.2.dist-info}/entry_points.txt +0 -0
- {yirgacheffe-1.7.0.dist-info → yirgacheffe-1.7.2.dist-info}/licenses/LICENSE +0 -0
- {yirgacheffe-1.7.0.dist-info → yirgacheffe-1.7.2.dist-info}/top_level.txt +0 -0
yirgacheffe/_core.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
-
from typing import
|
|
2
|
+
from typing import Optional, Sequence, Tuple, Union
|
|
3
3
|
|
|
4
4
|
from .layers.base import YirgacheffeLayer
|
|
5
5
|
from .layers.group import GroupLayer, TiledGroupLayer
|
|
@@ -32,7 +32,7 @@ def read_raster(
|
|
|
32
32
|
return RasterLayer.layer_from_file(filename, band, ignore_nodata)
|
|
33
33
|
|
|
34
34
|
def read_rasters(
|
|
35
|
-
filenames : Union[
|
|
35
|
+
filenames : Sequence[Union[Path,str]],
|
|
36
36
|
tiled: bool=False
|
|
37
37
|
) -> GroupLayer:
|
|
38
38
|
"""Open a set of raster files (e.g., GeoTIFFs) as a single layer.
|
yirgacheffe/layers/base.py
CHANGED
|
@@ -7,6 +7,7 @@ from .. import __version__
|
|
|
7
7
|
from ..operators import DataType, LayerMathMixin
|
|
8
8
|
from ..rounding import almost_equal, round_up_pixels, round_down_pixels
|
|
9
9
|
from ..window import Area, MapProjection, PixelScale, Window
|
|
10
|
+
from .._backends import backend
|
|
10
11
|
|
|
11
12
|
class YirgacheffeLayer(LayerMathMixin):
|
|
12
13
|
"""The common base class for the different layer types. Most still inherit from RasterLayer as deep down
|
|
@@ -310,6 +311,9 @@ class YirgacheffeLayer(LayerMathMixin):
|
|
|
310
311
|
)
|
|
311
312
|
return self._read_array_with_window(x, y, width, height, target_window)
|
|
312
313
|
|
|
314
|
+
def _read_array(self, x: int, y: int, width: int, height: int) -> Any:
|
|
315
|
+
return self._read_array_with_window(x, y, width, height, self.window)
|
|
316
|
+
|
|
313
317
|
def read_array(self, x: int, y: int, width: int, height: int) -> Any:
|
|
314
318
|
"""Reads data from the layer based on the current reference window.
|
|
315
319
|
|
|
@@ -329,7 +333,8 @@ class YirgacheffeLayer(LayerMathMixin):
|
|
|
329
333
|
Any
|
|
330
334
|
An array of values from the layer.
|
|
331
335
|
"""
|
|
332
|
-
|
|
336
|
+
res = self._read_array(x, y, width, height)
|
|
337
|
+
return backend.demote_array(res)
|
|
333
338
|
|
|
334
339
|
def latlng_for_pixel(self, x_coord: int, y_coord: int) -> Tuple[float,float]:
|
|
335
340
|
"""Get geo coords for pixel. This is relative to the set view window."""
|
yirgacheffe/layers/group.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
import copy
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
from typing import Any, List, Optional, Union
|
|
4
|
+
from typing import Any, List, Optional, Sequence, Union
|
|
5
5
|
|
|
6
6
|
import numpy as np
|
|
7
7
|
from numpy import ma
|
|
@@ -39,14 +39,14 @@ class GroupLayer(YirgacheffeLayer):
|
|
|
39
39
|
@classmethod
|
|
40
40
|
def layer_from_files(
|
|
41
41
|
cls,
|
|
42
|
-
filenames: Union[
|
|
42
|
+
filenames: Sequence[Union[Path,str]],
|
|
43
43
|
name: Optional[str] = None
|
|
44
44
|
) -> GroupLayer:
|
|
45
45
|
if filenames is None:
|
|
46
46
|
raise ValueError("filenames argument is None")
|
|
47
|
-
if len(filenames) < 1:
|
|
48
|
-
raise GroupLayerEmpty("No files found")
|
|
49
47
|
rasters: List[YirgacheffeLayer] = [RasterLayer.layer_from_file(x) for x in filenames]
|
|
48
|
+
if len(rasters) < 1:
|
|
49
|
+
raise GroupLayerEmpty("No files found")
|
|
50
50
|
return cls(rasters, name)
|
|
51
51
|
|
|
52
52
|
def __init__(
|
|
@@ -144,7 +144,7 @@ class GroupLayer(YirgacheffeLayer):
|
|
|
144
144
|
if len(contributing_layers) == 1:
|
|
145
145
|
layer, adjusted_layer_window, intersection = contributing_layers[0]
|
|
146
146
|
if target_window == intersection:
|
|
147
|
-
data = layer.
|
|
147
|
+
data = layer._read_array(
|
|
148
148
|
intersection.xoff - adjusted_layer_window.xoff,
|
|
149
149
|
intersection.yoff - adjusted_layer_window.yoff,
|
|
150
150
|
intersection.xsize,
|
|
@@ -156,11 +156,11 @@ class GroupLayer(YirgacheffeLayer):
|
|
|
156
156
|
|
|
157
157
|
result = np.zeros((ysize, xsize), dtype=float)
|
|
158
158
|
for layer, adjusted_layer_window, intersection in contributing_layers:
|
|
159
|
-
data = layer.
|
|
159
|
+
data = layer._read_array(
|
|
160
160
|
intersection.xoff - adjusted_layer_window.xoff,
|
|
161
161
|
intersection.yoff - adjusted_layer_window.yoff,
|
|
162
162
|
intersection.xsize,
|
|
163
|
-
intersection.ysize
|
|
163
|
+
intersection.ysize
|
|
164
164
|
)
|
|
165
165
|
result_x_offset = (intersection.xoff - xoffset) - window.xoff
|
|
166
166
|
result_y_offset = (intersection.yoff - yoffset) - window.yoff
|
|
@@ -269,7 +269,7 @@ class TiledGroupLayer(GroupLayer):
|
|
|
269
269
|
intersection = Window.find_intersection_no_throw([target_window, adjusted_layer_window])
|
|
270
270
|
if intersection is None:
|
|
271
271
|
continue
|
|
272
|
-
data = layer.
|
|
272
|
+
data = layer._read_array(
|
|
273
273
|
intersection.xoff - adjusted_layer_window.xoff,
|
|
274
274
|
intersection.yoff - adjusted_layer_window.yoff,
|
|
275
275
|
intersection.xsize,
|
yirgacheffe/layers/vectors.py
CHANGED
|
@@ -490,5 +490,9 @@ class VectorLayer(YirgacheffeLayer):
|
|
|
490
490
|
def _read_array_with_window(self, _x, _y, _width, _height, _window) -> Any:
|
|
491
491
|
assert NotRequired
|
|
492
492
|
|
|
493
|
-
def
|
|
493
|
+
def _read_array(self, x: int, y: int, width: int, height: int) -> Any:
|
|
494
494
|
return self._read_array_for_area(self.area, None, x, y, width, height)
|
|
495
|
+
|
|
496
|
+
def read_array(self, x: int, y: int, width: int, height: int) -> Any:
|
|
497
|
+
res = self._read_array(x, y, width, height)
|
|
498
|
+
return backend.demote_array(res)
|
yirgacheffe/operators.py
CHANGED
|
@@ -251,7 +251,7 @@ class LayerMathMixin:
|
|
|
251
251
|
self,
|
|
252
252
|
filename: Union[Path,str],
|
|
253
253
|
and_sum: bool = False,
|
|
254
|
-
parallelism:Optional[int]=None
|
|
254
|
+
parallelism:Optional[Union[int,bool]]=None
|
|
255
255
|
) -> Optional[float]:
|
|
256
256
|
return LayerOperation(self).to_geotiff(filename, and_sum, parallelism)
|
|
257
257
|
|
|
@@ -899,7 +899,7 @@ class LayerOperation(LayerMathMixin):
|
|
|
899
899
|
self,
|
|
900
900
|
filename: Union[Path,str],
|
|
901
901
|
and_sum: bool = False,
|
|
902
|
-
parallelism:Optional[int]=None
|
|
902
|
+
parallelism:Optional[Union[int,bool]] = None
|
|
903
903
|
) -> Optional[float]:
|
|
904
904
|
"""Saves a calculation to a raster file, optionally also returning the sum of pixels.
|
|
905
905
|
|
|
@@ -909,8 +909,9 @@ class LayerOperation(LayerMathMixin):
|
|
|
909
909
|
Path of the raster to save the result to.
|
|
910
910
|
and_sum : bool, default=False
|
|
911
911
|
If true then the function will also calculate the sum of the raster as it goes and return that value.
|
|
912
|
-
parallelism : int, optional, default=None
|
|
913
|
-
If passed, attempt to use multiple CPU cores up to the number provided
|
|
912
|
+
parallelism : int or bool, optional, default=None
|
|
913
|
+
If passed, attempt to use multiple CPU cores up to the number provided, or if set to True, yirgacheffe
|
|
914
|
+
will pick a sensible value.
|
|
914
915
|
|
|
915
916
|
Returns
|
|
916
917
|
-------
|
|
@@ -932,6 +933,9 @@ class LayerOperation(LayerMathMixin):
|
|
|
932
933
|
if parallelism is None:
|
|
933
934
|
result = self.save(layer, and_sum=and_sum)
|
|
934
935
|
else:
|
|
936
|
+
if isinstance(parallelism, bool):
|
|
937
|
+
# Parallel save treats None as "work it out"
|
|
938
|
+
parallelism = None
|
|
935
939
|
result = self.parallel_save(layer, and_sum=and_sum, parallelism=parallelism)
|
|
936
940
|
|
|
937
941
|
os.makedirs(target_dir, exist_ok=True)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
yirgacheffe/__init__.py,sha256=flTXNQQs6k8nboEv9O4eJnlv8kZ11z5zrfWcmUovCLg,537
|
|
2
|
-
yirgacheffe/_core.py,sha256=
|
|
2
|
+
yirgacheffe/_core.py,sha256=2CtRkVOpXBhFnj4fnpwSQBL3lJIvAmQJ4AgsMmKJOSs,4193
|
|
3
3
|
yirgacheffe/constants.py,sha256=uCWJwec3-ND-zVxYbsk1sdHKANl3ToNCTPg7MZb0j2g,434
|
|
4
|
-
yirgacheffe/operators.py,sha256=
|
|
4
|
+
yirgacheffe/operators.py,sha256=yFO43w05YNczxpWvRu7y223Lenu1sqLUHly0R4EWUbw,35925
|
|
5
5
|
yirgacheffe/rounding.py,sha256=ggBG4lMyLMtHLW3dBxr3gBCcF2qhRrY5etZiFGlIoqA,2258
|
|
6
6
|
yirgacheffe/window.py,sha256=0Wy3BT4SZLyviDwzLcX8LYOo2MeZ2zXCWAiJNpMbQpc,9505
|
|
7
7
|
yirgacheffe/_backends/__init__.py,sha256=jN-2iRrHStnPI6cNL7XhwhsROtI0EaGfIrbF5c-ECV0,334
|
|
@@ -10,16 +10,16 @@ yirgacheffe/_backends/mlx.py,sha256=2vOTMqHbQbeqt81Eq_8hxWDXZHaPsDpbXkALRVGEnnw,
|
|
|
10
10
|
yirgacheffe/_backends/numpy.py,sha256=cYO628s4-5K_-Bp3CrnHegzYSZfkt2QC8iE9oOOMtvA,4069
|
|
11
11
|
yirgacheffe/layers/__init__.py,sha256=mYKjw5YTcMNv_hMy7a6K4yRzIuNUbR8WuBTw4WIAmSk,435
|
|
12
12
|
yirgacheffe/layers/area.py,sha256=OFOM1_dMblzXLW29TwEqfdgSecl6aNs04bKJwUydLH0,3914
|
|
13
|
-
yirgacheffe/layers/base.py,sha256=
|
|
13
|
+
yirgacheffe/layers/base.py,sha256=4BjtEBzAHBWu06k-9Q7J1bm11xNILKDgA2cxuARxVyI,14344
|
|
14
14
|
yirgacheffe/layers/constant.py,sha256=XQ1ibeSckAcUOow-dMUlZiW5S2MKeFquOz_m8Y027GI,1437
|
|
15
|
-
yirgacheffe/layers/group.py,sha256=
|
|
15
|
+
yirgacheffe/layers/group.py,sha256=QyrECH5IthmBVV1debqttNvZGVocE-azdayJsvd6qqI,16096
|
|
16
16
|
yirgacheffe/layers/h3layer.py,sha256=Ys6F-e4Jre7lbFBYErF_4oidQx22WkWMKpHpQ7pPDTs,9875
|
|
17
17
|
yirgacheffe/layers/rasters.py,sha256=-yECyz3Odhy1er0ilJ9bfLUseI2cTHfwqhP-H3ImUKo,13365
|
|
18
18
|
yirgacheffe/layers/rescaled.py,sha256=hkvsd7paDCyUViABxrAXdXPOZegdwiphibkdrBuRclk,3366
|
|
19
|
-
yirgacheffe/layers/vectors.py,sha256=
|
|
20
|
-
yirgacheffe-1.7.
|
|
21
|
-
yirgacheffe-1.7.
|
|
22
|
-
yirgacheffe-1.7.
|
|
23
|
-
yirgacheffe-1.7.
|
|
24
|
-
yirgacheffe-1.7.
|
|
25
|
-
yirgacheffe-1.7.
|
|
19
|
+
yirgacheffe/layers/vectors.py,sha256=OpZaV2MgM0v4-CbrCNy_AHv3T2bvV9PFytolIzPPXFc,19900
|
|
20
|
+
yirgacheffe-1.7.2.dist-info/licenses/LICENSE,sha256=dNSHwUCJr6axStTKDEdnJtfmDdFqlE3h1NPCveqPfnY,757
|
|
21
|
+
yirgacheffe-1.7.2.dist-info/METADATA,sha256=5_xSRySwK7HSzhOKEPMcUzX1RpmVXH1E-CEmo5dhtsE,22351
|
|
22
|
+
yirgacheffe-1.7.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
23
|
+
yirgacheffe-1.7.2.dist-info/entry_points.txt,sha256=j4KgHXbVGbGyfTySc1ypBdERpfihO4WNjppvCdE9HjE,52
|
|
24
|
+
yirgacheffe-1.7.2.dist-info/top_level.txt,sha256=9DBFlKO2Ld3hG6TuE3qOTd3Tt8ugTiXil4AN4Wr9_y0,12
|
|
25
|
+
yirgacheffe-1.7.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|