rio-tiler 6.4.6__py3-none-any.whl → 6.5.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.6"
3
+ __version__ = "6.5.0"
4
4
 
5
5
  from . import ( # noqa
6
6
  colormap,
rio_tiler/io/base.py CHANGED
@@ -48,6 +48,18 @@ class SpatialMixin:
48
48
  def geographic_bounds(self) -> BBox:
49
49
  """Return dataset bounds in geographic_crs."""
50
50
  if self.crs == self.geographic_crs:
51
+ if self.bounds[1] > self.bounds[3]:
52
+ warnings.warn(
53
+ "BoundingBox of the dataset is inverted (minLat > maxLat).",
54
+ UserWarning,
55
+ )
56
+ return (
57
+ self.bounds[0],
58
+ self.bounds[3],
59
+ self.bounds[2],
60
+ self.bounds[1],
61
+ )
62
+
51
63
  return self.bounds
52
64
 
53
65
  try:
rio_tiler/io/xarray.py CHANGED
@@ -401,7 +401,7 @@ class XarrayReader(BaseReader):
401
401
 
402
402
  y, x = rowcol(ds.rio.transform(), ds_lon, ds_lat)
403
403
 
404
- arr = ds[:, y[0], x[0]].to_masked_array()
404
+ arr = ds[:, int(y[0]), int(x[0])].to_masked_array()
405
405
  arr.mask |= arr.data == ds.rio.nodata
406
406
 
407
407
  return PointData(
rio_tiler/reader.py CHANGED
@@ -142,11 +142,17 @@ def read(
142
142
  "crs": dst_crs,
143
143
  "add_alpha": True,
144
144
  "resampling": warp_resampling,
145
+ "dtype": src_dst.dtypes[0],
145
146
  }
146
147
 
147
148
  if nodata is not None:
148
149
  vrt_params.update(
149
- {"nodata": nodata, "add_alpha": False, "src_nodata": nodata}
150
+ {
151
+ "nodata": nodata,
152
+ "add_alpha": False,
153
+ "src_nodata": nodata,
154
+ "dtype": src_dst.dtypes[0],
155
+ }
150
156
  )
151
157
 
152
158
  if has_alpha_band(src_dst):
@@ -360,6 +366,8 @@ def part(
360
366
  vrt_transform, vrt_width, vrt_height = get_vrt_transform(
361
367
  src_dst,
362
368
  bounds,
369
+ height,
370
+ width,
363
371
  dst_crs=dst_crs,
364
372
  align_bounds_with_dataset=align_bounds_with_dataset,
365
373
  )
@@ -378,6 +386,8 @@ def part(
378
386
  vrt_transform, vrt_width, vrt_height = get_vrt_transform(
379
387
  src_dst,
380
388
  bounds,
389
+ height,
390
+ width,
381
391
  dst_crs=dst_crs,
382
392
  align_bounds_with_dataset=align_bounds_with_dataset,
383
393
  )
@@ -396,6 +406,7 @@ def part(
396
406
  "transform": vrt_transform,
397
407
  "width": vrt_width,
398
408
  "height": vrt_height,
409
+ "dtype": src_dst.dtypes[0],
399
410
  }
400
411
  if vrt_options:
401
412
  vrt_params.update(**vrt_options)
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
 
@@ -334,6 +334,23 @@ def get_vrt_transform(
334
334
  src_height = round(w.height)
335
335
  src_width = round(w.width)
336
336
 
337
+ # Specific FIX when bounds and transform are inverted
338
+ # See: https://github.com/US-GHG-Center/veda-config-ghg/pull/333
339
+ elif (
340
+ src_dst.crs == WGS84_CRS
341
+ and dst_crs == WEB_MERCATOR_CRS
342
+ and (src_bounds[1] > 85.06 or src_bounds[3] < -85.06)
343
+ ):
344
+ warnings.warn(
345
+ "Adjusting dataset latitudes to avoid re-projection overflow",
346
+ UserWarning,
347
+ )
348
+ src_bounds[1] = min(src_bounds[1], 85.06)
349
+ src_bounds[3] = max(src_bounds[3], -85.06)
350
+ w = windows.from_bounds(*src_bounds, transform=src_dst.transform)
351
+ src_height = round(w.height)
352
+ src_width = round(w.width)
353
+
337
354
  dst_transform, _, _ = calculate_default_transform(
338
355
  src_dst.crs, dst_crs, src_width, src_height, *src_bounds
339
356
  )
@@ -367,31 +384,35 @@ def get_vrt_transform(
367
384
 
368
385
  w, s, e, n = bounds
369
386
 
370
- # TODO: Explain
371
- if not height or not width:
372
- vrt_width = max(1, round((e - w) / dst_transform.a))
373
- vrt_height = max(1, round((s - n) / dst_transform.e))
374
- vrt_transform = from_bounds(w, s, e, n, vrt_width, vrt_height)
375
- return vrt_transform, vrt_width, vrt_height
376
-
377
- # TODO: Explain
378
- tile_transform = from_bounds(w, s, e, n, width, height)
379
- w_res = (
380
- tile_transform.a
381
- if abs(tile_transform.a) < abs(dst_transform.a)
382
- else dst_transform.a
383
- )
384
- h_res = (
385
- tile_transform.e
386
- if abs(tile_transform.e) < abs(dst_transform.e)
387
- else dst_transform.e
388
- )
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
+ )
389
412
 
390
- # TODO: Explain
391
413
  vrt_width = max(1, round((e - w) / w_res))
392
414
  vrt_height = max(1, round((s - n) / h_res))
393
415
  vrt_transform = from_bounds(w, s, e, n, vrt_width, vrt_height)
394
-
395
416
  return vrt_transform, vrt_width, vrt_height
396
417
 
397
418
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: rio-tiler
3
- Version: 6.4.6
3
+ Version: 6.5.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=lPcEhFftwoMm68E9w7LWjNrfH69Xfa_c9YW38R8aZwo,192
1
+ rio_tiler/__init__.py,sha256=SZiCYKyXS14zb5BZaGMXyw54dmXhNThkbH3vsF9fLRs,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
@@ -7,10 +7,10 @@ rio_tiler/logger.py,sha256=RR8lnW3uVXkFkPa3nNJS_tTndmdiNNDVXpCDGDxGf0A,81
7
7
  rio_tiler/models.py,sha256=TlJ0VoZVIzeMDTzdGIxmBKutLcMpxRAAdrcWg63T5Ts,28149
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=Ro_1siLCttt-fD6G3gsuL54amO-rPZbPv57VeIiiTGw,21610
10
+ rio_tiler/reader.py,sha256=DHI-YO0nVmTcz_BfPLUb-ZsRFMQzU1vHJOvnsTR4m2M,21927
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=37JLbIJSSO5LelWxAyBlrWwVCQLeEoUqrwD5EVlCyIs,26532
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
@@ -224,17 +224,17 @@ 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/io/__init__.py,sha256=_L4iILm6vSiJ14GEDDOvkuUHRtbWC9oqx6Bu8PxHhvA,270
227
- rio_tiler/io/base.py,sha256=SesiN4CsewPfIL92LjyWRePJzHVpiq7LL0PzRrVjWds,45246
227
+ rio_tiler/io/base.py,sha256=_NB2xkC0qgk87pt8ofqayHznEVXMzgClE1PUogy_FYw,45645
228
228
  rio_tiler/io/rasterio.py,sha256=XBq3b3zXLg9R1g0SbPR2DGH8g8UbgOsgHC9QVmoW6yM,32154
229
229
  rio_tiler/io/stac.py,sha256=4qU4mqssqzxyNYDNIB3U5x1D-9Q9aJyFF2hKUUDXJHg,10539
230
- rio_tiler/io/xarray.py,sha256=49GBiuxFQwGzBCOCAlzJDs9suewvRBaAxZGRQtHK9-U,17756
230
+ rio_tiler/io/xarray.py,sha256=0e562x2zXtIrHkzwNXStyHEtYE9z4dgEvCkW0aCHvyw,17766
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.4.6.dist-info/METADATA,sha256=40TT-QDJoa9g_86dtihyzxPG8z_cfjOTbMj9-6eZsrA,11920
237
- rio_tiler-6.4.6.dist-info/WHEEL,sha256=as-1oFTWSeWBgyzh0O_qF439xqBe6AbBgt4MfYe5zwY,87
238
- rio_tiler-6.4.6.dist-info/licenses/AUTHORS.txt,sha256=FCVd4Tjg-8syl0ZugCunpXER8X2-XonW2ZfllyTnRvE,158
239
- rio_tiler-6.4.6.dist-info/licenses/LICENSE,sha256=vq8Tt4KoYQT9JxAjQ4yXMmmhFYRTsBRgrOj-ao-bC5o,1517
240
- rio_tiler-6.4.6.dist-info/RECORD,,
236
+ rio_tiler-6.5.0.dist-info/METADATA,sha256=JYqf9bgGl8imf7grKE0luuceUrC03-GYySyfvV0SWDA,11920
237
+ rio_tiler-6.5.0.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
238
+ rio_tiler-6.5.0.dist-info/licenses/AUTHORS.txt,sha256=FCVd4Tjg-8syl0ZugCunpXER8X2-XonW2ZfllyTnRvE,158
239
+ rio_tiler-6.5.0.dist-info/licenses/LICENSE,sha256=vq8Tt4KoYQT9JxAjQ4yXMmmhFYRTsBRgrOj-ao-bC5o,1517
240
+ rio_tiler-6.5.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.22.5
2
+ Generator: hatchling 1.24.2
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any