cogeotiff / rio-tiler

User friendly Rasterio plugin to read raster datasets.
https://cogeotiff.github.io/rio-tiler/
BSD 3-Clause "New" or "Revised" License
502 stars 106 forks source link

Method to filter assets within mosaic_reader #682

Closed sor-droneup closed 6 months ago

sor-droneup commented 6 months ago

Hello,

I've noticed that for some mosaic the mosaic_reader function download some geotiffs before pixel selection, even if those geotiffs does not intersect with the tile (this happens in case if mosaic was generated with low zoom level).

A simple filter method could be added that would check if geotiff boundaries intersects with a tile before loading it, that would greatly reduce the execution time in scenarios like above.

Has this been considered before ? Is there any reason why there is no such filtering?

Such logics could be added for example in line 78 here: https://github.com/cogeotiff/rio-tiler/blob/73175d0607ef28bffcb6f03ff8dfd2d6abfbc191/rio_tiler/mosaic/reader.py#L25

vincentsarago commented 6 months ago

if the geotiff does not intersect with the tile, a TileOutsideBounds https://github.com/cogeotiff/rio-tiler/blob/main/rio_tiler/io/rasterio.py#L348-L351 should be raised. But in all the case, this will imply that the COG header will be downloaded and the COG dataset opened.

could you maybe explain a bit more and share a reproducible example 🙏