Unique values in raster table

1155
3
03-30-2012 11:05 AM
NareshPai
New Contributor
Is there a direct way to store all the unique values in raster attribute table? Right now, I am using a search cursor for attribute table and then, a for-loop to store the values. I wish GetRasterProperties_management would have "UNIQUEVALUES" in addition to the "UNIQUEVALUECOUNT"

Thanks,
Naresh
Tags (2)
0 Kudos
3 Replies
Zeke
by
Regular Contributor III
I don't work much with rasters, so maybe this wouldn't work or ArcGIS doesn't support it, but can you run a selection like a "Select Distinct Value..." to get unique values? If so, you could then export them into a table.
Sorry if I'm off base here, I'm thinking in SQL, maybe this is not even on the horizon with rasters.
0 Kudos
DarrenWiens2
MVP Honored Contributor
I assume you mean "store the individual values" (one row for each pixel)...? Raster attribute tables are a list of unique values.
0 Kudos
NareshPai
New Contributor
Hi Darren, Thanks for your response.

Yes, I would like to store all the values in the "Value" field of the table in a variable for categorical raster. The way I do it right now is,

k=0
rows = arcpy.SearchCursor(RasterName,"","","Value","")
for row in rows:
    val = row.getValue("Value")
    k = k + 1

Can this code be reduced?

Naresh
0 Kudos