[COG] Reading from the overviews in cog

Even Rouault even.rouault at spatialys.com
Tue Jun 12 07:42:58 PDT 2018


On mardi 12 juin 2018 16:20:47 CEST Grégory Bataille wrote:
> Hello everyone,
> 
> I’m trying to migrate my code to COG more and more rather than
> pre-computing some views/data.
> 
> I have had some great success with extracting partial full res raster
> values and it’s great.
> 
> One thing I have not been able to do so far though is « reading from the
> overview »
> Say for example I want to render a 512x512 tiles of data but really zoomed
> out. Let’s say for example that this tile contains my entire 10’000x10’000
> pixels geotiff. It’s obviously super inefficient to read from the raw
> raster rather than reading from one of the pre-computed overviews.
> Is there an API (python) to ask for raster data (between 2 points) (like
> ReadAsArray which is the one I currently use) but passing it the output
> size so that gdal can figure out which overview it’s better to read from?
> 

Grégory,

This is a GDAL question in fact :-)

Yes, the full signature of Dataset.ReadAsArray() is

    def ReadAsArray(self, xoff=0, yoff=0, xsize=None, ysize=None,
                    buf_obj=None,
                    buf_xsize=None, buf_ysize=None, buf_type=None,
                    resample_alg=gdalconst.GRIORA_NearestNeighbour,
                    callback=None,
                    callback_data=None,
                    interleave='band'):


So specify buf_xsize and buf_ysize (or pass a buf_obj of the appropriate 
output size)

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com



More information about the COG mailing list