cogeotiff / rio-cogeo

Cloud Optimized GeoTIFF creation and validation plugin for rasterio
https://cogeotiff.github.io/rio-cogeo/
BSD 3-Clause "New" or "Revised" License
315 stars 42 forks source link

mercantile.bounds for cog #227

Closed giswqs closed 2 years ago

giswqs commented 2 years ago

I am trying to create a function for creating COG from numpy array. Note the image does not necessarily cover the entire globe. How can we specify mercantile.bounds based on the image extent (southwest, northeast)?

https://cogeotiff.github.io/rio-cogeo/API/#using-the-api-with-in-memoryfile

bounds = mercantile.bounds(mercantile.Tile(0,0,0))

Here is a sample cog with 206 rows and 343 columns. image image

vincentsarago commented 2 years ago

👋 @giswqs

bounds is defined as (minx, miny, maxx, maxy) https://github.com/developmentseed/morecantile/blob/master/morecantile/commons.py#L6-L24

so from what you shared it will be (6.86, 53.39, 6.89, 53.416)

giswqs commented 2 years ago

It works. Many thanks!