rio-tiler 8.0.3__py3-none-any.whl → 8.0.5__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.
- rio_tiler/__init__.py +1 -1
- rio_tiler/colormap.py +6 -6
- rio_tiler/experimental/vsifile.py +1 -3
- rio_tiler/experimental/zarr.py +29 -28
- rio_tiler/expression.py +3 -3
- rio_tiler/io/base.py +73 -72
- rio_tiler/io/rasterio.py +67 -70
- rio_tiler/io/stac.py +25 -35
- rio_tiler/io/xarray.py +9 -9
- rio_tiler/models.py +46 -46
- rio_tiler/mosaic/backend.py +2 -2
- rio_tiler/mosaic/methods/base.py +3 -4
- rio_tiler/mosaic/methods/defaults.py +18 -19
- rio_tiler/mosaic/reader.py +20 -19
- rio_tiler/reader.py +41 -40
- rio_tiler/tasks.py +9 -8
- rio_tiler/types.py +16 -19
- rio_tiler/utils.py +33 -42
- {rio_tiler-8.0.3.dist-info → rio_tiler-8.0.5.dist-info}/METADATA +2 -1
- {rio_tiler-8.0.3.dist-info → rio_tiler-8.0.5.dist-info}/RECORD +23 -23
- {rio_tiler-8.0.3.dist-info → rio_tiler-8.0.5.dist-info}/WHEEL +0 -0
- {rio_tiler-8.0.3.dist-info → rio_tiler-8.0.5.dist-info}/licenses/AUTHORS.txt +0 -0
- {rio_tiler-8.0.3.dist-info → rio_tiler-8.0.5.dist-info}/licenses/LICENSE +0 -0
rio_tiler/utils.py
CHANGED
|
@@ -3,18 +3,9 @@
|
|
|
3
3
|
import math
|
|
4
4
|
import time
|
|
5
5
|
import warnings
|
|
6
|
+
from collections.abc import Callable, Generator
|
|
6
7
|
from io import BytesIO
|
|
7
|
-
from typing import
|
|
8
|
-
Any,
|
|
9
|
-
Callable,
|
|
10
|
-
Dict,
|
|
11
|
-
Generator,
|
|
12
|
-
List,
|
|
13
|
-
Optional,
|
|
14
|
-
Sequence,
|
|
15
|
-
Tuple,
|
|
16
|
-
Union,
|
|
17
|
-
)
|
|
8
|
+
from typing import Any, Sequence
|
|
18
9
|
|
|
19
10
|
import numpy
|
|
20
11
|
import rasterio
|
|
@@ -44,7 +35,7 @@ def _chunks(my_list: Sequence, chuck_size: int) -> Generator[Sequence, None, Non
|
|
|
44
35
|
yield my_list[i : i + chuck_size]
|
|
45
36
|
|
|
46
37
|
|
|
47
|
-
def _get_width_height(max_size, dataset_height, dataset_width) ->
|
|
38
|
+
def _get_width_height(max_size, dataset_height, dataset_width) -> tuple[int, int]:
|
|
48
39
|
"""Get Output Width/Height based on a max_size and dataset shape."""
|
|
49
40
|
if max(dataset_height, dataset_width) < max_size:
|
|
50
41
|
return dataset_height, dataset_width
|
|
@@ -60,7 +51,7 @@ def _get_width_height(max_size, dataset_height, dataset_width) -> Tuple[int, int
|
|
|
60
51
|
return height, width
|
|
61
52
|
|
|
62
53
|
|
|
63
|
-
def _missing_size(w:
|
|
54
|
+
def _missing_size(w: int | None = None, h: int | None = None):
|
|
64
55
|
"""Check if one and only one size (width, height) is valid."""
|
|
65
56
|
iterator = iter([w, h])
|
|
66
57
|
return any(iterator) and not any(iterator)
|
|
@@ -90,11 +81,11 @@ def _weighted_stdev(
|
|
|
90
81
|
def get_array_statistics(
|
|
91
82
|
data: numpy.ma.MaskedArray,
|
|
92
83
|
categorical: bool = False,
|
|
93
|
-
categories:
|
|
94
|
-
percentiles:
|
|
95
|
-
coverage:
|
|
84
|
+
categories: list[float] | None = None,
|
|
85
|
+
percentiles: list[int] | None = None,
|
|
86
|
+
coverage: NDArray[numpy.floating] | None = None,
|
|
96
87
|
**kwargs: Any,
|
|
97
|
-
) ->
|
|
88
|
+
) -> list[dict[Any, Any]]:
|
|
98
89
|
"""Calculate per band array statistics.
|
|
99
90
|
|
|
100
91
|
Args:
|
|
@@ -141,7 +132,7 @@ def get_array_statistics(
|
|
|
141
132
|
if len(data.shape) < 3:
|
|
142
133
|
data = numpy.ma.expand_dims(data, axis=0) # type: ignore [assignment]
|
|
143
134
|
|
|
144
|
-
output:
|
|
135
|
+
output: list[dict[Any, Any]] = []
|
|
145
136
|
percentiles_names = [f"percentile_{int(p)}" for p in percentiles]
|
|
146
137
|
|
|
147
138
|
if coverage is not None:
|
|
@@ -274,7 +265,7 @@ def _round_window(window: windows.Window) -> windows.Window:
|
|
|
274
265
|
|
|
275
266
|
|
|
276
267
|
def get_overview_level(
|
|
277
|
-
src_dst:
|
|
268
|
+
src_dst: DatasetReader | DatasetWriter | WarpedVRT,
|
|
278
269
|
bounds: BBox,
|
|
279
270
|
height: int,
|
|
280
271
|
width: int,
|
|
@@ -327,14 +318,14 @@ def get_overview_level(
|
|
|
327
318
|
|
|
328
319
|
|
|
329
320
|
def get_vrt_transform(
|
|
330
|
-
src_dst:
|
|
321
|
+
src_dst: DatasetReader | DatasetWriter | WarpedVRT,
|
|
331
322
|
bounds: BBox,
|
|
332
|
-
height:
|
|
333
|
-
width:
|
|
323
|
+
height: int | None = None,
|
|
324
|
+
width: int | None = None,
|
|
334
325
|
dst_crs: CRS = WEB_MERCATOR_CRS,
|
|
335
326
|
window_precision: int = 6,
|
|
336
327
|
align_bounds_with_dataset: bool = False,
|
|
337
|
-
) ->
|
|
328
|
+
) -> tuple[Affine, int, int]:
|
|
338
329
|
"""Calculate VRT transform.
|
|
339
330
|
|
|
340
331
|
Args:
|
|
@@ -468,7 +459,7 @@ def get_vrt_transform(
|
|
|
468
459
|
return vrt_transform, vrt_width, vrt_height
|
|
469
460
|
|
|
470
461
|
|
|
471
|
-
def has_alpha_band(src_dst:
|
|
462
|
+
def has_alpha_band(src_dst: DatasetReader | DatasetWriter | WarpedVRT) -> bool:
|
|
472
463
|
"""Check for alpha band or mask in source."""
|
|
473
464
|
if (
|
|
474
465
|
any(MaskFlags.alpha in flags for flags in src_dst.mask_flag_enums)
|
|
@@ -478,7 +469,7 @@ def has_alpha_band(src_dst: Union[DatasetReader, DatasetWriter, WarpedVRT]) -> b
|
|
|
478
469
|
return False
|
|
479
470
|
|
|
480
471
|
|
|
481
|
-
def has_mask_band(src_dst:
|
|
472
|
+
def has_mask_band(src_dst: DatasetReader | DatasetWriter | WarpedVRT) -> bool:
|
|
482
473
|
"""Check for mask band in source."""
|
|
483
474
|
if any(
|
|
484
475
|
(MaskFlags.per_dataset in flags and MaskFlags.alpha not in flags)
|
|
@@ -488,7 +479,7 @@ def has_mask_band(src_dst: Union[DatasetReader, DatasetWriter, WarpedVRT]) -> bo
|
|
|
488
479
|
return False
|
|
489
480
|
|
|
490
481
|
|
|
491
|
-
def non_alpha_indexes(src_dst:
|
|
482
|
+
def non_alpha_indexes(src_dst: DatasetReader | DatasetWriter | WarpedVRT) -> tuple:
|
|
492
483
|
"""Return indexes of non-alpha bands."""
|
|
493
484
|
return tuple(
|
|
494
485
|
b
|
|
@@ -524,7 +515,7 @@ def linear_rescale(
|
|
|
524
515
|
|
|
525
516
|
|
|
526
517
|
def _requested_tile_aligned_with_internal_tile(
|
|
527
|
-
src_dst:
|
|
518
|
+
src_dst: DatasetReader | DatasetWriter | WarpedVRT,
|
|
528
519
|
bounds: BBox,
|
|
529
520
|
bounds_crs: CRS = WEB_MERCATOR_CRS,
|
|
530
521
|
) -> bool:
|
|
@@ -553,9 +544,9 @@ def _requested_tile_aligned_with_internal_tile(
|
|
|
553
544
|
|
|
554
545
|
def render(
|
|
555
546
|
data: numpy.ndarray,
|
|
556
|
-
mask:
|
|
547
|
+
mask: numpy.ndarray | None = None,
|
|
557
548
|
img_format: str = "PNG",
|
|
558
|
-
colormap:
|
|
549
|
+
colormap: ColorMapType | None = None,
|
|
559
550
|
**creation_options: Any,
|
|
560
551
|
) -> bytes:
|
|
561
552
|
"""Translate numpy.ndarray to image bytes.
|
|
@@ -705,10 +696,10 @@ def pansharpening_brovey(
|
|
|
705
696
|
|
|
706
697
|
|
|
707
698
|
def _convert_to_raster_space(
|
|
708
|
-
src_dst:
|
|
709
|
-
poly_coordinates:
|
|
710
|
-
op:
|
|
711
|
-
) ->
|
|
699
|
+
src_dst: DatasetReader | DatasetWriter | WarpedVRT,
|
|
700
|
+
poly_coordinates: list,
|
|
701
|
+
op: Callable[[float], Any] | None = None,
|
|
702
|
+
) -> list[str]:
|
|
712
703
|
# NOTE: we could remove this once we have rasterio >= 1.4.2
|
|
713
704
|
op = op or numpy.floor
|
|
714
705
|
polygons = []
|
|
@@ -722,10 +713,10 @@ def _convert_to_raster_space(
|
|
|
722
713
|
|
|
723
714
|
|
|
724
715
|
def create_cutline(
|
|
725
|
-
src_dst:
|
|
726
|
-
geometry:
|
|
716
|
+
src_dst: DatasetReader | DatasetWriter | WarpedVRT,
|
|
717
|
+
geometry: dict,
|
|
727
718
|
geometry_crs: CRS = None,
|
|
728
|
-
op:
|
|
719
|
+
op: Callable[[float], Any] | None = None,
|
|
729
720
|
) -> str:
|
|
730
721
|
"""
|
|
731
722
|
Create WKT Polygon Cutline for GDALWarpOptions.
|
|
@@ -807,7 +798,7 @@ def resize_array(
|
|
|
807
798
|
resampling_method: RIOResampling = "nearest",
|
|
808
799
|
) -> numpy.ndarray:
|
|
809
800
|
"""resize array to a given height and width."""
|
|
810
|
-
out_shape:
|
|
801
|
+
out_shape: int | tuple[int, int] | tuple[int, int, int]
|
|
811
802
|
if len(data.shape) == 2:
|
|
812
803
|
out_shape = (height, width)
|
|
813
804
|
else:
|
|
@@ -841,7 +832,7 @@ def normalize_bounds(bounds: BBox) -> BBox:
|
|
|
841
832
|
)
|
|
842
833
|
|
|
843
834
|
|
|
844
|
-
def _validate_shape_input(shape:
|
|
835
|
+
def _validate_shape_input(shape: dict) -> dict:
|
|
845
836
|
"""Ensure input shape is valid and reduce features to geometry"""
|
|
846
837
|
|
|
847
838
|
if "geometry" in shape:
|
|
@@ -853,7 +844,7 @@ def _validate_shape_input(shape: Dict) -> Dict:
|
|
|
853
844
|
return shape
|
|
854
845
|
|
|
855
846
|
|
|
856
|
-
def cast_to_sequence(val:
|
|
847
|
+
def cast_to_sequence(val: Any | None = None) -> Sequence:
|
|
857
848
|
"""Cast input to sequence if not Tuple of List."""
|
|
858
849
|
if val is not None and not isinstance(val, (list, tuple)):
|
|
859
850
|
val = (val,)
|
|
@@ -861,7 +852,7 @@ def cast_to_sequence(val: Optional[Any] = None) -> Sequence:
|
|
|
861
852
|
return val
|
|
862
853
|
|
|
863
854
|
|
|
864
|
-
def _CRS_authority_info(crs: CRS) ->
|
|
855
|
+
def _CRS_authority_info(crs: CRS) -> tuple[str, str, str] | None:
|
|
865
856
|
"""Convert CRS to URI.
|
|
866
857
|
|
|
867
858
|
Code adapted from https://github.com/developmentseed/morecantile/blob/1829fe12408e4a1feee7493308f3f02257ef4caf/morecantile/models.py#L148-L161
|
|
@@ -879,7 +870,7 @@ def _CRS_authority_info(crs: CRS) -> Optional[Tuple[str, str, str]]:
|
|
|
879
870
|
return None
|
|
880
871
|
|
|
881
872
|
|
|
882
|
-
def CRS_to_uri(crs: CRS) ->
|
|
873
|
+
def CRS_to_uri(crs: CRS) -> str | None:
|
|
883
874
|
"""Convert CRS to URI."""
|
|
884
875
|
if info := _CRS_authority_info(crs):
|
|
885
876
|
authority, version, code = info
|
|
@@ -889,7 +880,7 @@ def CRS_to_uri(crs: CRS) -> Optional[str]:
|
|
|
889
880
|
return None
|
|
890
881
|
|
|
891
882
|
|
|
892
|
-
def CRS_to_urn(crs: CRS) ->
|
|
883
|
+
def CRS_to_urn(crs: CRS) -> str | None:
|
|
893
884
|
"""Convert CRS to URN."""
|
|
894
885
|
if info := _CRS_authority_info(crs):
|
|
895
886
|
authority, version, code = info
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rio-tiler
|
|
3
|
-
Version: 8.0.
|
|
3
|
+
Version: 8.0.5
|
|
4
4
|
Summary: User friendly Rasterio plugin to read raster datasets.
|
|
5
5
|
Project-URL: Homepage, https://cogeotiff.github.io/rio-tiler/
|
|
6
6
|
Project-URL: Documentation, https://cogeotiff.github.io/rio-tiler/
|
|
@@ -46,6 +46,7 @@ Classifier: License :: OSI Approved :: BSD License
|
|
|
46
46
|
Classifier: Programming Language :: Python :: 3.11
|
|
47
47
|
Classifier: Programming Language :: Python :: 3.12
|
|
48
48
|
Classifier: Programming Language :: Python :: 3.13
|
|
49
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
49
50
|
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
50
51
|
Requires-Python: >=3.11
|
|
51
52
|
Requires-Dist: attrs
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
rio_tiler/__init__.py,sha256=
|
|
2
|
-
rio_tiler/colormap.py,sha256=
|
|
1
|
+
rio_tiler/__init__.py,sha256=9I_AbcN_Q5q0cgOm8MkNY6J1X4ZALl8YEgSq2es0oac,192
|
|
2
|
+
rio_tiler/colormap.py,sha256=ttimH_pdXaPwCEtP20YAIPbk0t-FeglZaB2KEplOJjs,11308
|
|
3
3
|
rio_tiler/constants.py,sha256=55i-7JZDupTXZdLgxL03KsgM4lAzuGuIVP1zZKktzp0,426
|
|
4
4
|
rio_tiler/errors.py,sha256=GFAuE1AaSvx6dd0z5um9n3y1wVzUyQ5S8qY7_tXdrR8,2178
|
|
5
|
-
rio_tiler/expression.py,sha256=
|
|
5
|
+
rio_tiler/expression.py,sha256=kZhxXVL7j7c-9fMi8XeLlIzaYXNY2PhKg892jNeLEpk,2301
|
|
6
6
|
rio_tiler/logger.py,sha256=RR8lnW3uVXkFkPa3nNJS_tTndmdiNNDVXpCDGDxGf0A,81
|
|
7
|
-
rio_tiler/models.py,sha256=
|
|
7
|
+
rio_tiler/models.py,sha256=5ZSUWP-z5LP14X7vVaoOBFdJLsmAEBHTCW8N5J97dYs,35046
|
|
8
8
|
rio_tiler/profiles.py,sha256=EAx2JdcaOcMw5PZjxbCqQBXXWMac9mjtpHoVFPJEDNQ,1562
|
|
9
9
|
rio_tiler/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
-
rio_tiler/reader.py,sha256=
|
|
11
|
-
rio_tiler/tasks.py,sha256=
|
|
12
|
-
rio_tiler/types.py,sha256=
|
|
13
|
-
rio_tiler/utils.py,sha256
|
|
10
|
+
rio_tiler/reader.py,sha256=GTz_f3m3LH-UTn7dh6Jy1U_18R66X0QnmnFcWs4PhLM,24991
|
|
11
|
+
rio_tiler/tasks.py,sha256=rU4rpYFuTvPnWi8dp-lq0EBTOpQvQ-Gmo2eu0GcDKpE,3589
|
|
12
|
+
rio_tiler/types.py,sha256=pFw_rjzAfoebIS3-sxWWZa1LHIIUen4F0NnPmiqRfvA,1635
|
|
13
|
+
rio_tiler/utils.py,sha256=AeWxiOW07cn_bIWxXBp2PWsc11X0DtI1UFp2sdWFQto,32248
|
|
14
14
|
rio_tiler/cmap_data/__init__.py,sha256=8FtVmfpTjXlvhxQ5QesN0UC1m_B3MuF3LbGbhMC5Rw4,1039
|
|
15
15
|
rio_tiler/cmap_data/accent.npy,sha256=Qde1ldOoXghe4L05v1QbVvnMA1ldwNjKWPf5xCBbmI4,1152
|
|
16
16
|
rio_tiler/cmap_data/accent_r.npy,sha256=ba-GWSMSPRAcm9CGzlXJeNG4ABbBHDCV602hAWV2idc,1152
|
|
@@ -224,21 +224,21 @@ rio_tiler/cmap_data/ylorbr_r.npy,sha256=LjRoulX86uju7woCI_m4zzmAJMDpg-ky7p4f9vUk
|
|
|
224
224
|
rio_tiler/cmap_data/ylorrd.npy,sha256=9ImXljw40oe60w8uV4EMDPY4aFFVkGbyCBi6SlTX83w,1152
|
|
225
225
|
rio_tiler/cmap_data/ylorrd_r.npy,sha256=K5uiHNHbLxV5SizyT09cSVAxldE-BW5GpOXxUp7UsTE,1152
|
|
226
226
|
rio_tiler/experimental/__init__.py,sha256=dgW817h5U9OQt4V68L912g3DivPfhoWKvS-mI83sqio,328
|
|
227
|
-
rio_tiler/experimental/vsifile.py,sha256=
|
|
228
|
-
rio_tiler/experimental/zarr.py,sha256=
|
|
227
|
+
rio_tiler/experimental/vsifile.py,sha256=O_HeGz-eMM2voQ2lSREEUeHRb6fzvDj6jl_fhkspkII,937
|
|
228
|
+
rio_tiler/experimental/zarr.py,sha256=Lkz5WCNz6nRJTdvSKLCaSVaW2esSJDxyIsKr0pB6ppA,11753
|
|
229
229
|
rio_tiler/io/__init__.py,sha256=_L4iILm6vSiJ14GEDDOvkuUHRtbWC9oqx6Bu8PxHhvA,270
|
|
230
|
-
rio_tiler/io/base.py,sha256=
|
|
231
|
-
rio_tiler/io/rasterio.py,sha256=
|
|
232
|
-
rio_tiler/io/stac.py,sha256=
|
|
233
|
-
rio_tiler/io/xarray.py,sha256=
|
|
230
|
+
rio_tiler/io/base.py,sha256=qXaIybaTLRZjFvgLFX9XOEozrP-oGc8CTICFunvB0BE,53044
|
|
231
|
+
rio_tiler/io/rasterio.py,sha256=xwA-EM8FUfpWIW7X4-R-UExOayUzQ1PoCeRZGi2TRNs,28952
|
|
232
|
+
rio_tiler/io/stac.py,sha256=zMBmqMTakCX1fdjqlCO5KtoPaOsJUeL2AmUvWpoqlQc,12761
|
|
233
|
+
rio_tiler/io/xarray.py,sha256=QjVlTnwmVMmoaFCuxuHRYEXx5Zb1dK3ScJD4HTa0WU8,26968
|
|
234
234
|
rio_tiler/mosaic/__init__.py,sha256=Yj6CKpnFl8PJhLSp-a55wo33hKZ8-6OOBJtWA1HZVy8,118
|
|
235
|
-
rio_tiler/mosaic/backend.py,sha256=
|
|
236
|
-
rio_tiler/mosaic/reader.py,sha256=
|
|
235
|
+
rio_tiler/mosaic/backend.py,sha256=IkkYgcoSsWuvyaFMd-ViQufDeMl-kZlNobbHYA6A21s,8450
|
|
236
|
+
rio_tiler/mosaic/reader.py,sha256=FzSSMijL8KyKAw0JZ7u7dxzid_UKAVHmNKXwX4NVH44,10990
|
|
237
237
|
rio_tiler/mosaic/methods/__init__.py,sha256=tgkXM9skaTLXIm5QFoheOEznQXM97KGflcAWHfkrt1g,612
|
|
238
|
-
rio_tiler/mosaic/methods/base.py,sha256=
|
|
239
|
-
rio_tiler/mosaic/methods/defaults.py,sha256=
|
|
240
|
-
rio_tiler-8.0.
|
|
241
|
-
rio_tiler-8.0.
|
|
242
|
-
rio_tiler-8.0.
|
|
243
|
-
rio_tiler-8.0.
|
|
244
|
-
rio_tiler-8.0.
|
|
238
|
+
rio_tiler/mosaic/methods/base.py,sha256=E9QrriktsY1ACNXg1HEjQgZpEZZ7_oADYcDKRMWeNdk,1387
|
|
239
|
+
rio_tiler/mosaic/methods/defaults.py,sha256=L2pPOpQpH3yQT6AYXMSWoCev_swOi9Xc9jzBaXXs7_w,7566
|
|
240
|
+
rio_tiler-8.0.5.dist-info/METADATA,sha256=b7yu0aD1WmaaVza7whszSuRqZ8Sh54sDEFvwLox9WXY,11210
|
|
241
|
+
rio_tiler-8.0.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
242
|
+
rio_tiler-8.0.5.dist-info/licenses/AUTHORS.txt,sha256=FCVd4Tjg-8syl0ZugCunpXER8X2-XonW2ZfllyTnRvE,158
|
|
243
|
+
rio_tiler-8.0.5.dist-info/licenses/LICENSE,sha256=vq8Tt4KoYQT9JxAjQ4yXMmmhFYRTsBRgrOj-ao-bC5o,1517
|
|
244
|
+
rio_tiler-8.0.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|