[gdal-dev] python-gdal ComputStatistics return just two values

Even Rouault even.rouault at mines-paris.org
Fri Mar 27 14:45:05 EDT 2009


Hi Ivan,

I don't think there's a bug.

The C API for ComputeBandStats is :

CPLErr CPL_DLL CPL_STDCALL
GDALComputeBandStats( GDALRasterBandH hBand, int nSampleStep, 
                             double *pdfMean, double *pdfStdDev, 
                             GDALProgressFunc pfnProgress,
                             void *pProgressData );

So, the python API is consistant with it.

So it is expected that "bd1.SetStatistics(bd2.ComputeBandStats())" will fail 
as it is provided with 2 values instead of the expected 4.

Best regards,
Even

Le Friday 27 March 2009 19:02:14 Lucena, Ivan, vous avez écrit :
> Hi there,
>
> I believe that ComputeBandStats() should return 4 values min, max, mean and
> stddev) [1] but the Python API is returning just mean and stddev.
>
> python:
> >>> bd.ComputeBandStats()
>
> (9.0071713001936118, 11.350094331448236)
>
> >>> bd.ComputeRasterMinMax()
>
> (-1.7899999618530273, 31.149999618530273)
>
> gdalinfo:
>
> Band 1 Block=360x1 Type=Float32, ColorInterp=Gray
>   Min=-1.790 Max=31.150
>   Minimum=-1.790, Maximum=31.150, Mean=9.007, StdDev=11.350
>   Unit Type: unspecified
>   Metadata:
>     STATISTICS_MINIMUM=-1.789999961853
>     STATISTICS_MAXIMUM=31.14999961853
>     STATISTICS_MEAN=9.0071713001936
>     STATISTICS_STDDEV=11.350094331448
>
> Is that a bug?
>
> See what happens in that case:
> >>> bd1.SetStatistics(bd2.ComputeBandStats())
>
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in <module>
>   File "E:\Python25\Lib\site-packages\osgeo\gdal.py", line 729, in
> SetStatistics return _gdal.Band_SetStatistics(*args)
> TypeError: Band_SetStatistics() takes exactly 5 arguments (2 given)
>
> My best regards,
>
> Ivan
>
> [1] http://www.gdal.org/gdal_8h.html#a93b6b6ea6e71017ce25524e1a9ef1e3
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev




More information about the gdal-dev mailing list