I would like to get some advice on the most efficient way to return a list of unique values of a discrete-valued raster using Python and GDAL.
I had thought that the most obvious way would be to examine the raster's attribute table, but if I do
band.GetDefaultRAT() on the band of a raster dataset that contains an attribute table (the table is visible in ArcCatalog, anyway), the result is always
>>> rat = band.GetDefaultRAT() >>> rat == None True
In that case, I end up having to scan through each cell of the raster and build a list of unique values manually. Is this the only way to do it?
Or is there a way to build an attribute table with Python and GDAL, then query it for a list of unique values?