rio-tiler 6.4.7__py3-none-any.whl → 6.6.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  """rio-tiler."""
2
2
 
3
- __version__ = "6.4.7"
3
+ __version__ = "6.6.0"
4
4
 
5
5
  from . import ( # noqa
6
6
  colormap,
rio_tiler/io/rasterio.py CHANGED
@@ -265,11 +265,9 @@ class Reader(BaseReader):
265
265
  "width": self.dataset.width,
266
266
  "height": self.dataset.height,
267
267
  "overviews": self.dataset.overviews(1),
268
+ "scales": self.dataset.scales,
269
+ "offsets": self.dataset.offsets,
268
270
  }
269
- if self.dataset.scales[0] != 1.0 or self.dataset.offsets[0] != 0.0:
270
- meta.update(
271
- {"scale": self.dataset.scales[0], "offset": self.dataset.offsets[0]}
272
- )
273
271
 
274
272
  if self.colormap:
275
273
  meta.update({"colormap": self.colormap})
rio_tiler/models.py CHANGED
@@ -77,8 +77,8 @@ class Info(SpatialInfo):
77
77
  dtype: str
78
78
  nodata_type: Literal["Alpha", "Mask", "Internal", "Nodata", "None"]
79
79
  colorinterp: Optional[List[str]] = None
80
- scale: Optional[float] = None
81
- offset: Optional[float] = None
80
+ scales: Optional[List[float]] = None
81
+ offsets: Optional[List[float]] = None
82
82
  colormap: Optional[GDALColorMapType] = None
83
83
 
84
84
  model_config = {"extra": "allow"}
@@ -331,7 +331,7 @@ class ImageData:
331
331
  )
332
332
  crs: Optional[CRS] = attr.ib(default=None, kw_only=True)
333
333
  metadata: Optional[Dict] = attr.ib(factory=dict, kw_only=True)
334
- band_names: List[str] = attr.ib(kw_only=True)
334
+ band_names: Optional[List[str]] = attr.ib(kw_only=True)
335
335
  dataset_statistics: Optional[Sequence[Tuple[float, float]]] = attr.ib(
336
336
  default=None, kw_only=True
337
337
  )
rio_tiler/reader.py CHANGED
@@ -261,8 +261,13 @@ def read(
261
261
 
262
262
  if unscale:
263
263
  data = data.astype("float32", casting="unsafe")
264
- numpy.multiply(data, dataset.scales[0], out=data, casting="unsafe")
265
- numpy.add(data, dataset.offsets[0], out=data, casting="unsafe")
264
+
265
+ # reshaped to match data
266
+ scales = numpy.array(dataset.scales).reshape(-1, 1, 1)
267
+ offsets = numpy.array(dataset.offsets).reshape(-1, 1, 1)
268
+
269
+ numpy.multiply(data, scales, out=data, casting="unsafe")
270
+ numpy.add(data, offsets, out=data, casting="unsafe")
266
271
 
267
272
  if post_process:
268
273
  data = post_process(data)
@@ -366,6 +371,8 @@ def part(
366
371
  vrt_transform, vrt_width, vrt_height = get_vrt_transform(
367
372
  src_dst,
368
373
  bounds,
374
+ height,
375
+ width,
369
376
  dst_crs=dst_crs,
370
377
  align_bounds_with_dataset=align_bounds_with_dataset,
371
378
  )
@@ -384,6 +391,8 @@ def part(
384
391
  vrt_transform, vrt_width, vrt_height = get_vrt_transform(
385
392
  src_dst,
386
393
  bounds,
394
+ height,
395
+ width,
387
396
  dst_crs=dst_crs,
388
397
  align_bounds_with_dataset=align_bounds_with_dataset,
389
398
  )
rio_tiler/utils.py CHANGED
@@ -296,8 +296,8 @@ def get_vrt_transform(
296
296
  Args:
297
297
  src_dst (rasterio.io.DatasetReader or rasterio.io.DatasetWriter or rasterio.vrt.WarpedVRT): Rasterio dataset.
298
298
  bounds (tuple): Bounding box coordinates in target crs (**dst_crs**).
299
- height (int, optional): Desired output height of the array for the input bounds.
300
- width (int, optional): Desired output width of the array for the input bounds.
299
+ height (int, optional): Output height of the array for the input bounds.
300
+ width (int, optional): Output width of the array for the input bounds.
301
301
  dst_crs (rasterio.crs.CRS, optional): Target Coordinate Reference System. Defaults to `epsg:3857`.
302
302
  align_bounds_with_dataset (bool): Align input bounds with dataset transform. Defaults to `False`.
303
303
 
@@ -384,31 +384,35 @@ def get_vrt_transform(
384
384
 
385
385
  w, s, e, n = bounds
386
386
 
387
- # TODO: Explain
388
- if not height or not width:
389
- vrt_width = max(1, round((e - w) / dst_transform.a))
390
- vrt_height = max(1, round((s - n) / dst_transform.e))
391
- vrt_transform = from_bounds(w, s, e, n, vrt_width, vrt_height)
392
- return vrt_transform, vrt_width, vrt_height
393
-
394
- # TODO: Explain
395
- tile_transform = from_bounds(w, s, e, n, width, height)
396
- w_res = (
397
- tile_transform.a
398
- if abs(tile_transform.a) < abs(dst_transform.a)
399
- else dst_transform.a
400
- )
401
- h_res = (
402
- tile_transform.e
403
- if abs(tile_transform.e) < abs(dst_transform.e)
404
- else dst_transform.e
405
- )
387
+ # When no output size (resolution) - Use Dataset Resolution
388
+ # NOTE: When we don't `fix` the output width/height, we're using the reprojected dataset resolution
389
+ # to calculate what is the size/transform of the VRT
390
+ w_res = dst_transform.a
391
+ h_res = dst_transform.e
392
+
393
+ # NOTE: When we have desired output height/width, we can use them to
394
+ # calculate the output size/transform. The VRT resolution will be aligned with the desired
395
+ # output resolution (if not bigger)
396
+ if height and width:
397
+ output_transform = from_bounds(w, s, e, n, width, height)
398
+
399
+ # NOTE: Here we check if the Output Resolution is higher thant the dataset resolution (OverZoom)
400
+ # When not overzooming we don't want to use the output Width/Height to calculate the transform
401
+ # See issues https://github.com/cogeotiff/rio-tiler/pull/648
402
+ w_res = (
403
+ output_transform.a
404
+ if abs(output_transform.a) < abs(dst_transform.a)
405
+ else dst_transform.a
406
+ )
407
+ h_res = (
408
+ output_transform.e
409
+ if abs(output_transform.e) < abs(dst_transform.e)
410
+ else dst_transform.e
411
+ )
406
412
 
407
- # TODO: Explain
408
413
  vrt_width = max(1, round((e - w) / w_res))
409
414
  vrt_height = max(1, round((s - n) / h_res))
410
415
  vrt_transform = from_bounds(w, s, e, n, vrt_width, vrt_height)
411
-
412
416
  return vrt_transform, vrt_width, vrt_height
413
417
 
414
418
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: rio-tiler
3
- Version: 6.4.7
3
+ Version: 6.6.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,16 +1,16 @@
1
- rio_tiler/__init__.py,sha256=vHddqRd_9wVkQaEb950PsIvnUUDBxfLLiDKLLnMEB80,192
1
+ rio_tiler/__init__.py,sha256=KBppTQcprO6lj0jdPe52UbbmBDGLXnQ-eDtixrPuB1Q,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=ag-wNr13JaQ4YcQzWWPFzjegeGdzJIMMrOrbb3coQ40,1733
5
5
  rio_tiler/expression.py,sha256=EVHWgjMqIn4TTPfqT_HV1RWCQlxqOj3OtEr1iUDiFHE,2282
6
6
  rio_tiler/logger.py,sha256=RR8lnW3uVXkFkPa3nNJS_tTndmdiNNDVXpCDGDxGf0A,81
7
- rio_tiler/models.py,sha256=TlJ0VoZVIzeMDTzdGIxmBKutLcMpxRAAdrcWg63T5Ts,28149
7
+ rio_tiler/models.py,sha256=slIxi1xjIdJ0fr1UmOxZzD3KGkJ3DADsC9DKEO5CjJM,28173
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=t8iMYYjfKKGvtSH7ljUdbmdilbTC50_98PwtTrFC7Ek,21841
10
+ rio_tiler/reader.py,sha256=Bi8BbeIF7BDSOPLEyb153tdNQIiZgTY4l4vteg5FqN8,22080
11
11
  rio_tiler/tasks.py,sha256=tiQo24rZHBVxids40QkNInuMzDFEei08zYW3I_pkSVE,3157
12
12
  rio_tiler/types.py,sha256=508_E5R-nKrAo8TWB-6h7pF6SYwNM8kJPiHjQw-k-tA,1443
13
- rio_tiler/utils.py,sha256=ZbOG2eCHBY5gx82LcqLQzPMOy0kQ4Mimy1aA_6w0dAE,27257
13
+ rio_tiler/utils.py,sha256=3TBlnQVFA-2igDpMrwxhjN_Quvc8t21xv7sQkM7e6dQ,27748
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
@@ -225,7 +225,7 @@ rio_tiler/cmap_data/ylorrd.npy,sha256=9ImXljw40oe60w8uV4EMDPY4aFFVkGbyCBi6SlTX83
225
225
  rio_tiler/cmap_data/ylorrd_r.npy,sha256=K5uiHNHbLxV5SizyT09cSVAxldE-BW5GpOXxUp7UsTE,1152
226
226
  rio_tiler/io/__init__.py,sha256=_L4iILm6vSiJ14GEDDOvkuUHRtbWC9oqx6Bu8PxHhvA,270
227
227
  rio_tiler/io/base.py,sha256=_NB2xkC0qgk87pt8ofqayHznEVXMzgClE1PUogy_FYw,45645
228
- rio_tiler/io/rasterio.py,sha256=XBq3b3zXLg9R1g0SbPR2DGH8g8UbgOsgHC9QVmoW6yM,32154
228
+ rio_tiler/io/rasterio.py,sha256=GW77fhWHPU1Ue8hifZhJA99pWDomsahJ9EDfVvu7GBo,32042
229
229
  rio_tiler/io/stac.py,sha256=4qU4mqssqzxyNYDNIB3U5x1D-9Q9aJyFF2hKUUDXJHg,10539
230
230
  rio_tiler/io/xarray.py,sha256=0e562x2zXtIrHkzwNXStyHEtYE9z4dgEvCkW0aCHvyw,17766
231
231
  rio_tiler/mosaic/__init__.py,sha256=Yj6CKpnFl8PJhLSp-a55wo33hKZ8-6OOBJtWA1HZVy8,118
@@ -233,8 +233,8 @@ rio_tiler/mosaic/reader.py,sha256=_YBwTJwHvXOzKwpNpOmmh0F4yicyxgWo9vHyof3w_Do,96
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.4.7.dist-info/METADATA,sha256=4SBddP6XLK-3pFOJGuxuW0gCfemnF-upGM-1mYXR8As,11920
237
- rio_tiler-6.4.7.dist-info/WHEEL,sha256=osohxoshIHTFJFVPhsi1UkZuLRGMHRXZzwEBW2ezjrc,87
238
- rio_tiler-6.4.7.dist-info/licenses/AUTHORS.txt,sha256=FCVd4Tjg-8syl0ZugCunpXER8X2-XonW2ZfllyTnRvE,158
239
- rio_tiler-6.4.7.dist-info/licenses/LICENSE,sha256=vq8Tt4KoYQT9JxAjQ4yXMmmhFYRTsBRgrOj-ao-bC5o,1517
240
- rio_tiler-6.4.7.dist-info/RECORD,,
236
+ rio_tiler-6.6.0.dist-info/METADATA,sha256=7LKGbh4UH_R9XzxsXyHezpUM7fg0wdzC1y3tsdlmcTs,11920
237
+ rio_tiler-6.6.0.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
238
+ rio_tiler-6.6.0.dist-info/licenses/AUTHORS.txt,sha256=FCVd4Tjg-8syl0ZugCunpXER8X2-XonW2ZfllyTnRvE,158
239
+ rio_tiler-6.6.0.dist-info/licenses/LICENSE,sha256=vq8Tt4KoYQT9JxAjQ4yXMmmhFYRTsBRgrOj-ao-bC5o,1517
240
+ rio_tiler-6.6.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.24.1
2
+ Generator: hatchling 1.24.2
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any