Skip to content

Accessing COG overviews with read_rasterio #3269

Closed
@rsignell-usgs

Description

@rsignell-usgs

It's considered best practice to create cloud-optimized geotiff (COG) with overviews, which are essentially copies of the dataset at different resolutions to allow fast representation at different scales.

It would be nice if we could pick a specific overview using xr.read_rasterio, perhaps by just an additional parameter on the call, like xr.read_rasterio(url, overview=512) or something.

Currently we need to use Rasterio to find out what the overlays are, for example:

url = 'https://esip-pangeo-uswest2.s3-us-west-2.amazonaws.com/sciencebase/Southern_California_Topobathy_DEM_1m_cog.tif'
src = rasterio.open(url, 'r')
[src.overviews(i) for i in src.indexes]

which results in:

[[4, 8, 16, 32, 64, 128, 256, 512, 1023]]

See the notebook here for the hack workaround to extract an overlay from COG:
https://nbviewer.jupyter.org/gist/rsignell-usgs/dc4cf94fae97d085f6f2b9b896ec5336

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions