Opened 17 years ago

Closed 17 years ago

#1641 closed defect (fixed)

GetStatistics() returns wrong list in Python

Reported by: warmerdam Owned by: hobu
Priority: normal Milestone: 1.5.0
Component: PythonBindings Version: unspecified
Severity: normal Keywords:
Cc:

Description

import gdal
ds = gdal.Open('utm.tif')
print ds.GetRasterBand(1).GetStatistics(1,1)

reports: [0, 0.0, 255.0, 104.44825962611607, 56.757824326870313] but it should report [0.0, 255.0, 104.44825962611607, 56.757824326870313]. That is, an extra zero entry is being returned in the list.

This problem seems to be related to this call in Band.i:

%apply (double *OUTPUT){double *min, double *max, double *mean, double *stddev};
  CPLErr GetStatistics( int approx_ok, int force, 
                      double *min, double *max, double *mean, double *stddev ){
    return GDALGetRasterStatistics( self, approx_ok, force, 
				    min, max, mean, stddev );
  }
%clear (CPLErr);

Note that there are only four return values.

I am using SWIG 1.3.31. This was observed on trunk. I haven't check 1.4.x.

Change History (3)

comment:1 by warmerdam, 17 years ago

PS. This causes autotest/gdrivers/hfa.py when run against the NG bindings.

comment:2 by hobu, 17 years ago

Milestone: 1.5.0

fixed in r11530

comment:3 by hobu, 17 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.