Select to view content in your preferred language

recording pixel value with Python script in ArcGIS 10.x

3931
11
01-10-2014 12:56 PM
DeanPodolsky
Emerging Contributor
A scripting newbie question...

I'd like to write a Python script for ArcGIS 10.x that would record the pixel value for all pixels in a raster. Furthermore, I'd like to only record a given value once in the results. For example, if there are 23 values of 180 overall, only record one instance of that value.

The raster in question is 4-band so the results would have to include values for all pixels in each band, recorded separately by band. The Pixel Inspector tool (see image below) will show you the value per pixel (and surrounding pixels), but I'd like to record the values as described.

Any help and examples would be greatly appreciated. Thanks in advance.


[ATTACH=CONFIG]30411[/ATTACH]
Tags (2)
0 Kudos
11 Replies
ChrisBater
Deactivated User
Rather than use a set, I wonder if you can use numpy's "unique" function, with "return_index=True" if necessary.

Check this out: http://docs.scipy.org/doc/numpy/reference/generated/numpy.unique.html

Chris
0 Kudos
DouglasSands
Deactivated User
The numpy unique function will return all of the unique values from the entire array, rather than for each row. You could loop over the rows/sub-arrays in the 2d array and call numpy.unique on them, but I compared numpy vs list looping for something I was working and found that converting to list first and going row by row was faster than going row by row over the numpy array.
0 Kudos