cogeotiff / rio-tiler-mosaic

A rio-tiler plugin for creating tiles from multiple observations.
MIT License
32 stars 6 forks source link

mosaicing arbitary bounding boxes #10

Open spolloni opened 5 years ago

spolloni commented 5 years ago

Salut Vincent!

thanks for the wonderful suite of tools you're building here. I am looking for utils or code snippets in either rio-tiler-mosaic or rio-tiler that would help build an equivalent of the mosaic_tiler function, but accepting an arbitrary bbox rather than a (x,y,z) tuple. Any pointers?

Also, would such a function be a meaningful contribution to this repo? would be happy to take a stab at a PR if that interests you.

vincentsarago commented 5 years ago

Hi @spolloni, This is totally possible. in https://github.com/cogeotiff/rio-tiler-mosaic/blob/bde4ffee51b0387b366450aaf4954af894d06573/rio_tiler_mosaic/mosaic.py#L85

we pass x,y,z because mosaic_tiler expects the user to provide rio_tiler.{module}.tile function: https://github.com/cogeotiff/rio-tiler-mosaic/blob/bde4ffee51b0387b366450aaf4954af894d06573/rio_tiler_mosaic/mosaic.py#L60-L61

But this could be replaced by rio_tiler.utils.tile_read function https://github.com/cogeotiff/rio-tiler/blob/master/rio_tiler/utils.py#L439 which accepts bounds instead of XYZ info

I could totally add another function called mosaic_tiler_bounds.

The idea of using .tile method from rio-tiler submodule was to let rio-tiler handle errors for tile outside bounds and also make rio-tiler-mosaic as simple as possible

spolloni commented 5 years ago

Thanks for the reply @vincentsarago !

The idea of using .tile method from rio-tiler submodule was to let rio-tiler handle errors for tile outside bounds and also make rio-tiler-mosaic as simple as possible

that makes a lot of sense, and in general I think that adhering to the XYZ model is great for keeping rio-tiler-mosaic's API simple and convenient. With that said, given the raster data is ultimately retrieved using rasterio windowed reads, I think there is a case for exposing that in the API as well.

I think a function such as mosaic_tiler_bounds would be a great addition, since it would avoid having to request all intersecting XYZ tiles (and then "stitching" them) when needing an arbitrary bbox from multiple COGs.

Let me know if I can assist somehow.