Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 (6017x7715) 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 and save it in Excel or at the very least a .csv.

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

EDIT: I've found this online and it seems to work toward what I need:

import arcpy
raster = arcpy.Raster("m_4112013_ne_10_1_20100627.tif")

array = arcpy.RasterToNumPyArray(raster) 
(height, width)=array.shape for row in   range(0,height): 
for col in range(0,width): 
    print str(row)+","+str(col)+":"+str(array.item(row,col))

Now I'm working on getting my output the way I want. Any comments?

share|improve this question

migrated from stackoverflow.com Jan 30 '14 at 5:32

This question came from our site for professional and enthusiast programmers.

What have you tried? Arcpy do have a function for converting rasters to numpy arrays. –  M4rtini Jan 12 '14 at 0:48
This question seems to have morphed, which is OK because no one has invested any obvious amount of time into Answer-ing or Comment-ing, but can you now revise it so that your current question, becomes clear, please? –  PolyGeo Jan 30 '14 at 10:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.