Opened 10 years ago

Closed 10 years ago

#5468 closed defect (fixed)

VRT ComputeStatistics() doesn't work on VRT that are a sub-window of source dataset

Reported by: Even Rouault Owned by: Even Rouault
Priority: normal Milestone: 1.10.2
Component: GDAL_Raster Version: 1.10.0
Severity: normal Keywords: vrt statistics
Cc:

Description

From http://lists.osgeo.org/pipermail/gdal-dev/2014-May/039047.html

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.

Change History (1)

comment:1 by Even Rouault, 10 years ago

Milestone: 1.10.2
Resolution: fixed
Status: newclosed

trunk r27319, branches/1.11 r27320, branches/1.10 r27321 "VRT: fix ComputeStatistics() on VRT that are a sub-window of source dataset (#5468)"

Note: See TracTickets for help on using tickets.