[gdal-dev] VRT ComputeStatistics fails because of self-reference

Matt Gregory matt.gregory at oregonstate.edu
Tue May 13 14:36:49 PDT 2014


Hi all,

I'm trying to compute statistics on a VRT file using the python 
band.ComputeStatistics method.  I'm using GDAL 1.10.1 on a Windows 7 
64-bit box.

First, I create a VRT clip of a larger raster using gdal_translate, e.g.

   gdal_translate -of VRT -projwin <sub_window> in.tif out.vrt

Then, in Python, I try to compute statistics:

   ds = gdal.OpenShared('out.vrt', gdalconst.GA_ReadOnly)
   rb = ds.GetRasterBand(1)
   (min, max, mean, std) = rb.ComputeStatistics(False)

This fails with many messages of:

   ERROR 1: VRTSourcedRasterBand::IRasterIO() called recursively on
     the same band.
   It looks like the VRT is referencing itself.
   ERROR 1: test.vrt, band 29: IReadBlock failed at X offset 1, Y
     offset 3

I can replicate the same behavior by first creating the VRT using 
gdal_translate and then calling gdalinfo -stats on it.

I see in the code that I'm triggering the bAntiRecursionFlag within the 
GetMinimum and GetMaximum member functions, but unclear how this is 
coming about.

thanks for help,
matt



More information about the gdal-dev mailing list