record pixel value with Python script

D

DPod

A scripting newbie question...

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.

Any help and examples would be greatly appreciated.
 
M

maxerickson

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
 
D

DPod

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 anAPI for fetching a band.



The filtering step is easy, you just want the set of values:



set(red)





Max

No, installing libraries doesn't seem to be an option
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,078
Latest member
MakersCBDBlood

Latest Threads

Top