[gdal-dev] GeoTiff Class Cell Counts

Frank Warmerdam warmerdam at pobox.com
Thu Oct 15 15:38:29 EDT 2009

Seth Girvin wrote:
> Hi,
> I have just started using the GDAL functions through the .NET wrapper 
> written by Tamas Szekeres.
> I can get statistics on my GeoTIFF which is great, but I need to get the 
> count of pixels in each class in the raster.
> Ideally I want to get the count by a range e.g. 123787 cells between 0 - 
> 0.25, 3242353 cells between 0.25-0.5. Would I need to read through all 
> cells individually? I can't seem to find a way to do this using GDAL 
> command line tools, so I'm not sure what function name I should be 
> looking out for.


You can generate a histogram with the GDAL API and you can control the
bucket extents as long as they are equal width.

The python script histrep.py demonstrates using this, but the function
should also be accessable from C#.


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