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

Lucena, Ivan ivan.lucena at pmldnet.com
Fri Mar 27 15:05:11 EDT 2009


Even,

I see. You are right. With the absence of ComputeRasterStatistics() I got confused and I made the wrong 
assumption. BTW, why there is no wrapper for ComputeRasterStatistics()? That would work then:

>>> bd1.SetStatistics(bd2.ComputeRasterStatistics())

Not a big deal. The work around is easy.

Thank you very much,

Ivan


>  -------Original Message-------
>  From: Even Rouault <even.rouault at mines-paris.org>
>  Subject: Re: [gdal-dev] python-gdal ComputStatistics return just two values
>  Sent: Mar 27 '09 18:45
>  
>  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