Re: Speed up reading rasters


Even Rouault
 

On dimanche 26 avril 2020 03:04:56 CEST carlogarro@... wrote:

> Hello, I need to read many huge datasets and the speed time is very

> important to avoid a bottleneck. I have to read a tiff file that has 20

> bands, and a window of 224,224. Now I am doing like this, and it takes

> approx 0.8seconds.

>

> with rasterio.open('./sentinel.tif') as src:

> sentinel1_1 = src.read(window=window)

>

> What I realized is that if I try to read only one of the bands the required

> time is approx the same, but when reading a tiff of only one band the

> amount of time is 10 times shorter.

>

> Can I do something to speed it up? Maybe read bands in parallel, I don't

> really know.

 

If you have control on how the creation of the TIFF file, make sure it uses Band interleaving instead of Pixel interleaving

 

For example, with gdal_translate can be done with -co INTERLEAVE=BAND

 

If the file is not tiled, adding tiling might also help.

 

I see in https://rasterio.readthedocs.io/en/latest/topics/profiles.html a pure rasterio way of creating such file

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com

Join main@rasterio.groups.io to automatically receive all group messages.