rio-tiler 7.1.0__py3-none-any.whl → 7.2.1__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 +21 -9
- rio_tiler/io/stac.py +19 -4
- rio_tiler/io/xarray.py +7 -1
- rio_tiler/types.py +4 -0
- {rio_tiler-7.1.0.dist-info → rio_tiler-7.2.1.dist-info}/METADATA +2 -3
- {rio_tiler-7.1.0.dist-info → rio_tiler-7.2.1.dist-info}/RECORD +10 -10
- {rio_tiler-7.1.0.dist-info → rio_tiler-7.2.1.dist-info}/WHEEL +1 -1
- {rio_tiler-7.1.0.dist-info → rio_tiler-7.2.1.dist-info}/licenses/AUTHORS.txt +0 -0
- {rio_tiler-7.1.0.dist-info → rio_tiler-7.2.1.dist-info}/licenses/LICENSE +0 -0
rio_tiler/__init__.py
CHANGED
rio_tiler/colormap.py
CHANGED
|
@@ -4,6 +4,7 @@ import json
|
|
|
4
4
|
import os
|
|
5
5
|
import pathlib
|
|
6
6
|
import re
|
|
7
|
+
import warnings
|
|
7
8
|
from typing import Dict, List, Sequence, Tuple, Union
|
|
8
9
|
|
|
9
10
|
import attr
|
|
@@ -18,6 +19,7 @@ from rio_tiler.errors import (
|
|
|
18
19
|
from rio_tiler.types import (
|
|
19
20
|
ColorMapType,
|
|
20
21
|
DataMaskType,
|
|
22
|
+
DiscreteColorMapType,
|
|
21
23
|
GDALColorMapType,
|
|
22
24
|
IntervalColorMapType,
|
|
23
25
|
)
|
|
@@ -116,28 +118,38 @@ def apply_cmap(data: numpy.ndarray, colormap: ColorMapType) -> DataMaskType:
|
|
|
116
118
|
# rio_tiler.colormap.make_lut, because we don't want to create a `lookup table`
|
|
117
119
|
# with more than 256 entries (256 x 4) array. In this case we use `apply_discrete_cmap`
|
|
118
120
|
# which can work with arbitrary colormap dict.
|
|
119
|
-
if
|
|
121
|
+
if (
|
|
122
|
+
len(colormap) != 256
|
|
123
|
+
or max(colormap) >= 256
|
|
124
|
+
or min(colormap) < 0
|
|
125
|
+
or any(isinstance(k, float) for k in colormap)
|
|
126
|
+
):
|
|
120
127
|
return apply_discrete_cmap(data, colormap)
|
|
121
128
|
|
|
122
|
-
|
|
129
|
+
# For now we assume ColorMap are in uint8
|
|
130
|
+
if data.dtype != numpy.uint8:
|
|
131
|
+
warnings.warn(
|
|
132
|
+
f"Input array is of type {data.dtype} and `will be converted to Int in order to apply the ColorMap.",
|
|
133
|
+
UserWarning,
|
|
134
|
+
)
|
|
135
|
+
data = data.astype(numpy.uint8)
|
|
136
|
+
|
|
137
|
+
lookup_table = make_lut(colormap) # type: ignore
|
|
123
138
|
data = lookup_table[data[0], :]
|
|
124
139
|
|
|
125
140
|
data = numpy.transpose(data, [2, 0, 1])
|
|
126
141
|
|
|
127
|
-
# If the colormap has values between 0-255
|
|
128
|
-
# we cast the output array to Uint8.
|
|
129
|
-
if data.min() >= 0 and data.max() <= 255:
|
|
130
|
-
data = data.astype("uint8")
|
|
131
|
-
|
|
132
142
|
return data[:-1], data[-1]
|
|
133
143
|
|
|
134
144
|
|
|
135
|
-
def apply_discrete_cmap(
|
|
145
|
+
def apply_discrete_cmap(
|
|
146
|
+
data: numpy.ndarray, colormap: Union[GDALColorMapType, DiscreteColorMapType]
|
|
147
|
+
) -> DataMaskType:
|
|
136
148
|
"""Apply discrete colormap.
|
|
137
149
|
|
|
138
150
|
Args:
|
|
139
151
|
data (numpy.ndarray): 1D image array to translate to RGB.
|
|
140
|
-
colormap (GDALColorMapType): Discrete ColorMap dictionary.
|
|
152
|
+
colormap (GDALColorMapType or DiscreteColorMapType): Discrete ColorMap dictionary.
|
|
141
153
|
|
|
142
154
|
Returns:
|
|
143
155
|
tuple: Data (numpy.ndarray) and Alpha band (numpy.ndarray).
|
rio_tiler/io/stac.py
CHANGED
|
@@ -3,7 +3,18 @@
|
|
|
3
3
|
import json
|
|
4
4
|
import os
|
|
5
5
|
import warnings
|
|
6
|
-
from typing import
|
|
6
|
+
from typing import (
|
|
7
|
+
Any,
|
|
8
|
+
Dict,
|
|
9
|
+
Iterator,
|
|
10
|
+
List,
|
|
11
|
+
Optional,
|
|
12
|
+
Sequence,
|
|
13
|
+
Set,
|
|
14
|
+
Tuple,
|
|
15
|
+
Type,
|
|
16
|
+
Union,
|
|
17
|
+
)
|
|
7
18
|
from urllib.parse import urlparse
|
|
8
19
|
|
|
9
20
|
import attr
|
|
@@ -273,7 +284,13 @@ class STACReader(MultiBaseReader):
|
|
|
273
284
|
self.minzoom = self.minzoom if self.minzoom is not None else self._minzoom
|
|
274
285
|
self.maxzoom = self.maxzoom if self.maxzoom is not None else self._maxzoom
|
|
275
286
|
|
|
276
|
-
self.assets =
|
|
287
|
+
self.assets = self.get_asset_list()
|
|
288
|
+
if not self.assets:
|
|
289
|
+
raise MissingAssets("No valid asset found. Asset's media types not supported")
|
|
290
|
+
|
|
291
|
+
def get_asset_list(self) -> List[str]:
|
|
292
|
+
"""Get valid asset list"""
|
|
293
|
+
return list(
|
|
277
294
|
_get_assets(
|
|
278
295
|
self.item,
|
|
279
296
|
include=self.include_assets,
|
|
@@ -282,8 +299,6 @@ class STACReader(MultiBaseReader):
|
|
|
282
299
|
exclude_asset_types=self.exclude_asset_types,
|
|
283
300
|
)
|
|
284
301
|
)
|
|
285
|
-
if not self.assets:
|
|
286
|
-
raise MissingAssets("No valid asset found. Asset's media types not supported")
|
|
287
302
|
|
|
288
303
|
def _get_reader(self, asset_info: AssetInfo) -> Tuple[Type[BaseReader], Dict]:
|
|
289
304
|
"""Get Asset Reader."""
|
rio_tiler/io/xarray.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import warnings
|
|
6
|
-
from typing import Dict, List, Optional
|
|
6
|
+
from typing import Any, Dict, List, Optional
|
|
7
7
|
|
|
8
8
|
import attr
|
|
9
9
|
import numpy
|
|
@@ -156,6 +156,7 @@ class XarrayReader(BaseReader):
|
|
|
156
156
|
percentiles: Optional[List[int]] = None,
|
|
157
157
|
hist_options: Optional[Dict] = None,
|
|
158
158
|
nodata: Optional[NoData] = None,
|
|
159
|
+
**kwargs: Any,
|
|
159
160
|
) -> Dict[str, BandStatistics]:
|
|
160
161
|
"""Return statistics from a dataset."""
|
|
161
162
|
hist_options = hist_options or {}
|
|
@@ -188,6 +189,7 @@ class XarrayReader(BaseReader):
|
|
|
188
189
|
reproject_method: WarpResampling = "nearest",
|
|
189
190
|
auto_expand: bool = True,
|
|
190
191
|
nodata: Optional[NoData] = None,
|
|
192
|
+
**kwargs: Any,
|
|
191
193
|
) -> ImageData:
|
|
192
194
|
"""Read a Web Map tile from a dataset.
|
|
193
195
|
|
|
@@ -264,6 +266,7 @@ class XarrayReader(BaseReader):
|
|
|
264
266
|
height: Optional[int] = None,
|
|
265
267
|
width: Optional[int] = None,
|
|
266
268
|
resampling_method: RIOResampling = "nearest",
|
|
269
|
+
**kwargs: Any,
|
|
267
270
|
) -> ImageData:
|
|
268
271
|
"""Read part of a dataset.
|
|
269
272
|
|
|
@@ -362,6 +365,7 @@ class XarrayReader(BaseReader):
|
|
|
362
365
|
dst_crs: Optional[CRS] = None,
|
|
363
366
|
reproject_method: WarpResampling = "nearest",
|
|
364
367
|
resampling_method: RIOResampling = "nearest",
|
|
368
|
+
**kwargs: Any,
|
|
365
369
|
) -> ImageData:
|
|
366
370
|
"""Return a preview of a dataset.
|
|
367
371
|
|
|
@@ -446,6 +450,7 @@ class XarrayReader(BaseReader):
|
|
|
446
450
|
lat: float,
|
|
447
451
|
coord_crs: CRS = WGS84_CRS,
|
|
448
452
|
nodata: Optional[NoData] = None,
|
|
453
|
+
**kwargs: Any,
|
|
449
454
|
) -> PointData:
|
|
450
455
|
"""Read a pixel value from a dataset.
|
|
451
456
|
|
|
@@ -499,6 +504,7 @@ class XarrayReader(BaseReader):
|
|
|
499
504
|
height: Optional[int] = None,
|
|
500
505
|
width: Optional[int] = None,
|
|
501
506
|
resampling_method: RIOResampling = "nearest",
|
|
507
|
+
**kwargs: Any,
|
|
502
508
|
) -> ImageData:
|
|
503
509
|
"""Read part of a dataset defined by a geojson feature.
|
|
504
510
|
|
rio_tiler/types.py
CHANGED
|
@@ -18,11 +18,15 @@ IntervalTuple = Tuple[NumType, NumType] # (0, 100)
|
|
|
18
18
|
# ColorMap Dict: {1: (0, 0, 0, 255), ...}
|
|
19
19
|
GDALColorMapType = Dict[int, ColorTuple]
|
|
20
20
|
|
|
21
|
+
# Discrete Colormap, like GDALColorMapType but accept Float: {0.1: (0, 0, 0, 255), ...}
|
|
22
|
+
DiscreteColorMapType = Dict[NumType, ColorTuple]
|
|
23
|
+
|
|
21
24
|
# Intervals ColorMap: [((0, 1), (0, 0, 0, 0)), ...]
|
|
22
25
|
IntervalColorMapType = Sequence[Tuple[IntervalTuple, ColorTuple]]
|
|
23
26
|
|
|
24
27
|
ColorMapType = Union[
|
|
25
28
|
GDALColorMapType,
|
|
29
|
+
DiscreteColorMapType,
|
|
26
30
|
IntervalColorMapType,
|
|
27
31
|
]
|
|
28
32
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: rio-tiler
|
|
3
|
-
Version: 7.1
|
|
3
|
+
Version: 7.2.1
|
|
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/
|
|
@@ -37,8 +37,6 @@ License: BSD 3-Clause License
|
|
|
37
37
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
38
38
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
39
39
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
40
|
-
License-File: AUTHORS.txt
|
|
41
|
-
License-File: LICENSE
|
|
42
40
|
Keywords: COGEO,Cloud Optimized Geotiff,STAC,rasterio,slippy-map
|
|
43
41
|
Classifier: Intended Audience :: Information Technology
|
|
44
42
|
Classifier: Intended Audience :: Science/Research
|
|
@@ -79,6 +77,7 @@ Provides-Extra: s3
|
|
|
79
77
|
Requires-Dist: boto3; extra == 's3'
|
|
80
78
|
Provides-Extra: test
|
|
81
79
|
Requires-Dist: boto3; extra == 'test'
|
|
80
|
+
Requires-Dist: h5netcdf; extra == 'test'
|
|
82
81
|
Requires-Dist: morecantile<7.0,>=6.0; extra == 'test'
|
|
83
82
|
Requires-Dist: pytest; extra == 'test'
|
|
84
83
|
Requires-Dist: pytest-cov; extra == 'test'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
rio_tiler/__init__.py,sha256=
|
|
2
|
-
rio_tiler/colormap.py,sha256=
|
|
1
|
+
rio_tiler/__init__.py,sha256=OB3FKef6gLmJCPcAVLXOm65pGXyYbM3Woy6hlUUTb7o,192
|
|
2
|
+
rio_tiler/colormap.py,sha256=Ale0ToTrEKwP3JOhrySYKuQsfeeTgJT1YGBcmdssJ0k,11411
|
|
3
3
|
rio_tiler/constants.py,sha256=55i-7JZDupTXZdLgxL03KsgM4lAzuGuIVP1zZKktzp0,426
|
|
4
4
|
rio_tiler/errors.py,sha256=4I3i0e1FtkLX5sIX6dfhUMUj3SWWoKqkjCkSG7k5i2M,1901
|
|
5
5
|
rio_tiler/expression.py,sha256=EVHWgjMqIn4TTPfqT_HV1RWCQlxqOj3OtEr1iUDiFHE,2282
|
|
@@ -9,7 +9,7 @@ rio_tiler/profiles.py,sha256=EAx2JdcaOcMw5PZjxbCqQBXXWMac9mjtpHoVFPJEDNQ,1562
|
|
|
9
9
|
rio_tiler/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
10
|
rio_tiler/reader.py,sha256=FiDQQU_v8mDk2JTxBpLmsTqaCQFOsjOw0LocasLeXjk,22721
|
|
11
11
|
rio_tiler/tasks.py,sha256=tiQo24rZHBVxids40QkNInuMzDFEei08zYW3I_pkSVE,3157
|
|
12
|
-
rio_tiler/types.py,sha256=
|
|
12
|
+
rio_tiler/types.py,sha256=wrGiiGBQ-WdzHf-lEypiH3cub7Knu_rXJw7EWZ2FAS8,1632
|
|
13
13
|
rio_tiler/utils.py,sha256=_msIyfmDtvNnk3MGIENfGurTs2_Fb-hJ-YughEi82Rc,29507
|
|
14
14
|
rio_tiler/cmap_data/__init__.py,sha256=8FtVmfpTjXlvhxQ5QesN0UC1m_B3MuF3LbGbhMC5Rw4,1039
|
|
15
15
|
rio_tiler/cmap_data/accent.npy,sha256=Qde1ldOoXghe4L05v1QbVvnMA1ldwNjKWPf5xCBbmI4,1152
|
|
@@ -226,15 +226,15 @@ rio_tiler/cmap_data/ylorrd_r.npy,sha256=K5uiHNHbLxV5SizyT09cSVAxldE-BW5GpOXxUp7U
|
|
|
226
226
|
rio_tiler/io/__init__.py,sha256=_L4iILm6vSiJ14GEDDOvkuUHRtbWC9oqx6Bu8PxHhvA,270
|
|
227
227
|
rio_tiler/io/base.py,sha256=nyaAtfodM-5fXd1WsGG5Qh544PNv9Hy4FLQ_nPj8hw8,52154
|
|
228
228
|
rio_tiler/io/rasterio.py,sha256=9GtbUPialsFMnxVUKrJ8ZItC3sWS8zddrO8aiPG07AU,29011
|
|
229
|
-
rio_tiler/io/stac.py,sha256=
|
|
230
|
-
rio_tiler/io/xarray.py,sha256=
|
|
229
|
+
rio_tiler/io/stac.py,sha256=CbIfS060m9ZZrQvPeE1Kxv5IBXn4Se9U6h9A5mQsBaI,12796
|
|
230
|
+
rio_tiler/io/xarray.py,sha256=zuNhrtlutmA1zrD_9zB2x6UWQOGSvuiI5wUcx7VIjcQ,20624
|
|
231
231
|
rio_tiler/mosaic/__init__.py,sha256=Yj6CKpnFl8PJhLSp-a55wo33hKZ8-6OOBJtWA1HZVy8,118
|
|
232
232
|
rio_tiler/mosaic/reader.py,sha256=_YBwTJwHvXOzKwpNpOmmh0F4yicyxgWo9vHyof3w_Do,9686
|
|
233
233
|
rio_tiler/mosaic/methods/__init__.py,sha256=tgkXM9skaTLXIm5QFoheOEznQXM97KGflcAWHfkrt1g,612
|
|
234
234
|
rio_tiler/mosaic/methods/base.py,sha256=9YZJWVRwH5Fk9KO9q5CW52Q8Mf60tAJ21oM4ixEDXBo,1424
|
|
235
235
|
rio_tiler/mosaic/methods/defaults.py,sha256=z34lna2wGXnAPwculjk_6hDrloqS8wzer68FFoIo7pg,6744
|
|
236
|
-
rio_tiler-7.1.
|
|
237
|
-
rio_tiler-7.1.
|
|
238
|
-
rio_tiler-7.1.
|
|
239
|
-
rio_tiler-7.1.
|
|
240
|
-
rio_tiler-7.1.
|
|
236
|
+
rio_tiler-7.2.1.dist-info/METADATA,sha256=9zT-xK6xrp_qJGaYX_kweOSXuP31RpDbYomHceUfSPc,12202
|
|
237
|
+
rio_tiler-7.2.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
|
238
|
+
rio_tiler-7.2.1.dist-info/licenses/AUTHORS.txt,sha256=FCVd4Tjg-8syl0ZugCunpXER8X2-XonW2ZfllyTnRvE,158
|
|
239
|
+
rio_tiler-7.2.1.dist-info/licenses/LICENSE,sha256=vq8Tt4KoYQT9JxAjQ4yXMmmhFYRTsBRgrOj-ao-bC5o,1517
|
|
240
|
+
rio_tiler-7.2.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|