[Gdal-dev] statistics of a band

Frank Warmerdam warmerdam at pobox.com
Mon May 17 10:30:16 EDT 2004


Amlacher Katrin wrote:
> Hi,
> 
> many file formats supports storing the statistic of a band. For my work 
> it is important to read and write such statistic (inclusive mean and 
> stdev ). I have seen, that HFA can read the statistic, but I couldn't 
> find an interface to get the data.
> 
> Are there any interfaces for reading and writing statistical data (other 
> than minimum and maximum) planned for gdal?
> 
> What is the best way to read and write statistical data at the moment?

Katrin,

At the time of your writing this message there was no way to get the statistics
information from Imagine files via the GDAL API.  However, I have added support
for min/max to be returned via the GetMinimum() and GetMaximum() methods and for
the rest of the statistics node information to be returned as metadata.  So now,
a gdalinfo report on a .img file might look like this:


Driver: HFA/Erdas Imagine Images (.img)
Size is 278, 190
Coordinate System is:
LOCAL_CS["TM103_30",
     UNIT["meters",1]]
Origin = (465807.000000,930351.000000)
Pixel Size = (20.00000000,-20.00000000)
Corner Coordinates:
Upper Left  (  465807.000,  930351.000)
Lower Left  (  465807.000,  926551.000)
Upper Right (  471367.000,  930351.000)
Lower Right (  471367.000,  926551.000)
Center      (  468587.000,  928451.000)
Band 1 Block=64x64 Type=Float64, ColorInterp=Undefined
   Min=1356.400 Max=3857.100
   Overviews: 68x46
Metadata:
   STATISTICS_MINIMUM=1356.4000244141
   STATISTICS_MAXIMUM=3857.1000976562
   STATISTICS_MEAN=2723.8083008922
   STATISTICS_MEDIAN=2772.8121752739
   STATISTICS_MODE=3163.546561718
   STATISTICS_STDDEV=569.70285788543

If you need this capability you will need to upgrade to the latest GDAL from
CVS or if you already have a reasonably recent version you should be able
to replace gdal/frmts/hfa/hfadataset.cpp with the file at the following
url and rebuild:

   http://gdal.velocet.ca/~warmerda/hfadataset.cpp

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list