record pixel value with Python script
maxerickson at gmail.com
maxerickson at gmail.com
Sat Jan 11 18:35:13 EST 2014
On Saturday, January 11, 2014 5:53:00 PM UTC-5, DPod wrote:
>
> I'd like to write a Python script for ArcGIS 10.x (ArcPy or Python 2.6.5) >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 (6017 x 7715 pixels) so the results would >have to include values for all pixels in each band, recorded separately by >band. Ideally I'd like to write to an Excel file or at least a .csv file.
>
Can you install libraries?
Fetching the pixel values of an individual band is straightforward in PIL (and the fork Pillow), something like this:
from PIL import Image
im=Image.open("blah.jpg")
red=im.getdata(0)
If you can't install things you would need to figure out if ArcGIS has an API for fetching a band.
The filtering step is easy, you just want the set of values:
set(red)
Max
More information about the Python-list
mailing list