rio-tiler 6.7.0__py3-none-any.whl → 6.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.
- rio_tiler/__init__.py +1 -1
- rio_tiler/io/stac.py +34 -5
- {rio_tiler-6.7.0.dist-info → rio_tiler-6.8.0.dist-info}/METADATA +1 -1
- {rio_tiler-6.7.0.dist-info → rio_tiler-6.8.0.dist-info}/RECORD +7 -7
- {rio_tiler-6.7.0.dist-info → rio_tiler-6.8.0.dist-info}/WHEEL +0 -0
- {rio_tiler-6.7.0.dist-info → rio_tiler-6.8.0.dist-info}/licenses/AUTHORS.txt +0 -0
- {rio_tiler-6.7.0.dist-info → rio_tiler-6.8.0.dist-info}/licenses/LICENSE +0 -0
rio_tiler/__init__.py
CHANGED
rio_tiler/io/stac.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import json
|
|
4
4
|
import os
|
|
5
5
|
import warnings
|
|
6
|
-
from typing import Any, Dict, Iterator, Optional, Set, Type, Union
|
|
6
|
+
from typing import Any, Dict, Iterator, Optional, Set, Tuple, Type, Union
|
|
7
7
|
from urllib.parse import urlparse
|
|
8
8
|
|
|
9
9
|
import attr
|
|
@@ -41,6 +41,8 @@ DEFAULT_VALID_TYPE = {
|
|
|
41
41
|
"application/x-hdf",
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
STAC_ALTERNATE_KEY = os.environ.get("RIO_TILER_STAC_ALTERNATE_KEY", None)
|
|
45
|
+
|
|
44
46
|
|
|
45
47
|
def aws_get_object(
|
|
46
48
|
bucket: str,
|
|
@@ -275,16 +277,34 @@ class STACReader(MultiBaseReader):
|
|
|
275
277
|
def _maxzoom(self):
|
|
276
278
|
return self.tms.maxzoom
|
|
277
279
|
|
|
280
|
+
def _parse_vrt_asset(self, asset: str) -> Tuple[str, Optional[str]]:
|
|
281
|
+
if asset.startswith("vrt://") and asset not in self.assets:
|
|
282
|
+
parsed = urlparse(asset)
|
|
283
|
+
if not parsed.netloc:
|
|
284
|
+
raise InvalidAssetName(
|
|
285
|
+
f"'{asset}' is not valid, couldn't find valid asset"
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
if parsed.netloc not in self.assets:
|
|
289
|
+
raise InvalidAssetName(
|
|
290
|
+
f"'{parsed.netloc}' is not valid, should be one of {self.assets}"
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
return parsed.netloc, parsed.query
|
|
294
|
+
|
|
295
|
+
return asset, None
|
|
296
|
+
|
|
278
297
|
def _get_asset_info(self, asset: str) -> AssetInfo:
|
|
279
|
-
"""Validate asset names and return asset's
|
|
298
|
+
"""Validate asset names and return asset's info.
|
|
280
299
|
|
|
281
300
|
Args:
|
|
282
301
|
asset (str): STAC asset name.
|
|
283
302
|
|
|
284
303
|
Returns:
|
|
285
|
-
|
|
304
|
+
AssetInfo: STAC asset info.
|
|
286
305
|
|
|
287
306
|
"""
|
|
307
|
+
asset, vrt_options = self._parse_vrt_asset(asset)
|
|
288
308
|
if asset not in self.assets:
|
|
289
309
|
raise InvalidAssetName(
|
|
290
310
|
f"'{asset}' is not valid, should be one of {self.assets}"
|
|
@@ -295,13 +315,19 @@ class STACReader(MultiBaseReader):
|
|
|
295
315
|
|
|
296
316
|
info = AssetInfo(
|
|
297
317
|
url=asset_info.get_absolute_href() or asset_info.href,
|
|
298
|
-
metadata=extras,
|
|
318
|
+
metadata=extras if not vrt_options else None,
|
|
299
319
|
)
|
|
300
320
|
|
|
321
|
+
if STAC_ALTERNATE_KEY and extras.get("alternate"):
|
|
322
|
+
if alternate := extras["alternate"].get(STAC_ALTERNATE_KEY):
|
|
323
|
+
info["url"] = alternate["href"]
|
|
324
|
+
|
|
325
|
+
# https://github.com/stac-extensions/file
|
|
301
326
|
if head := extras.get("file:header_size"):
|
|
302
327
|
info["env"] = {"GDAL_INGESTED_BYTES_AT_OPEN": head}
|
|
303
328
|
|
|
304
|
-
|
|
329
|
+
# https://github.com/stac-extensions/raster
|
|
330
|
+
if (bands := extras.get("raster:bands")) and not vrt_options:
|
|
305
331
|
stats = [
|
|
306
332
|
(b["statistics"]["minimum"], b["statistics"]["maximum"])
|
|
307
333
|
for b in bands
|
|
@@ -319,4 +345,7 @@ class STACReader(MultiBaseReader):
|
|
|
319
345
|
"Some statistics data in STAC are invalid, they will be ignored."
|
|
320
346
|
)
|
|
321
347
|
|
|
348
|
+
if vrt_options:
|
|
349
|
+
info["url"] = f"vrt://{info['url']}?{vrt_options}"
|
|
350
|
+
|
|
322
351
|
return info
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: rio-tiler
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.8.0
|
|
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/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
rio_tiler/__init__.py,sha256=
|
|
1
|
+
rio_tiler/__init__.py,sha256=WefaHHGITJ0r36AfTpJwoVUhiaJ44_3n4Pc0yGes0so,192
|
|
2
2
|
rio_tiler/colormap.py,sha256=uXeK2p-h6fMqTaCogHWkDP6AqJDtKCpCHa5ylRdEnj0,9775
|
|
3
3
|
rio_tiler/constants.py,sha256=55i-7JZDupTXZdLgxL03KsgM4lAzuGuIVP1zZKktzp0,426
|
|
4
4
|
rio_tiler/errors.py,sha256=4I3i0e1FtkLX5sIX6dfhUMUj3SWWoKqkjCkSG7k5i2M,1901
|
|
@@ -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=5VW27CGXkYN45pTegacCZpl0tv9liAFLeWOSchOeFZg,45651
|
|
228
228
|
rio_tiler/io/rasterio.py,sha256=J0DyUq2lBrsmaey2411abBZw5Kp8V4PD2Y0dlTRU7S0,32038
|
|
229
|
-
rio_tiler/io/stac.py,sha256=
|
|
229
|
+
rio_tiler/io/stac.py,sha256=yzbHnlzVdMft9PZmS0Pi79aZo_lFgerguMQS_O91ul4,11722
|
|
230
230
|
rio_tiler/io/xarray.py,sha256=B6W03YJIkgdsGR-2_GcYt3q4vRCYJ728IbAhQoVWPX4,18514
|
|
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-6.
|
|
237
|
-
rio_tiler-6.
|
|
238
|
-
rio_tiler-6.
|
|
239
|
-
rio_tiler-6.
|
|
240
|
-
rio_tiler-6.
|
|
236
|
+
rio_tiler-6.8.0.dist-info/METADATA,sha256=-8MnnRnyMujOnmYzecic3Ik7eYU-Ch61pM44GiU7_ZI,11967
|
|
237
|
+
rio_tiler-6.8.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
238
|
+
rio_tiler-6.8.0.dist-info/licenses/AUTHORS.txt,sha256=FCVd4Tjg-8syl0ZugCunpXER8X2-XonW2ZfllyTnRvE,158
|
|
239
|
+
rio_tiler-6.8.0.dist-info/licenses/LICENSE,sha256=vq8Tt4KoYQT9JxAjQ4yXMmmhFYRTsBRgrOj-ao-bC5o,1517
|
|
240
|
+
rio_tiler-6.8.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|