[gdal-dev] Getting unique values from a raster band

Tom Jeffery tjeffery at gmail.com
Mon Mar 21 08:28:24 EDT 2011


What is the proper way to extract all the unique values contained in a
raster Band object?  I had initially assumed that if a RasterAttributeTable
object existed, it would contain a "Value" column, but I have come across
instances where the only column in the table is a "Histogram" field
containing the counts of each pixel value, but not the value itself.

Currently, I check for the existence of the table, check to see if it has a
Value column, and if not, inspect each pixel value to get the unique set.
The pixel scanning fallback method is quite slow, however, and when I view
the same rasters in ArcCatalog and bring up the "Table" view, it is able to
instantly display the typical Value / Count table.  Is there some trick I'm
missing here on how to get these values?

Thanks very much!
Tom Jeffery
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110321/5f45f927/attachment.html


More information about the gdal-dev mailing list