[gdal-dev] GeoTiff Class Cell Counts

Jose Gomez-Dans jgomezdans at gmail.com
Wed Oct 14 05:48:05 EDT 2009


Hi,

2009/10/14 Seth Girvin <sgirvin at gmail.com>

> 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.
>

I know nothing about the C# bindings, but using the python bindings, you can
get a histogram, and change its bin buckets around to your satisfaction:
g = gdal.Open(my_fname)
b = g.GetRasterBand(1)
h = b.GetHistogram()


J
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20091014/30625726/attachment.html


More information about the gdal-dev mailing list