# How do I get the values of each cell in the raster attribute table?

How do I get the values of each cell in the raster attribute table. Usually the attribute table gives you the value and number of counts. But, in my case I want each cell listed and corresponding cell values.

Thank bunch..!

-

Convert the grid to a point shapefile using Raster To Point Conversion, then view/edit/export that file's table.

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001200000007000000

-

I notice you didn't mention Python at all, but it is possible to output a raster as a numpy array (arcpy.RasterToNumPyArray). Then you can iterate over the rows and columns of the array to get your result.

Assuming this is the output you want:

``````x    y    value
0    0    0
0    1    0
0    2    1
1    0    0
1    1    1
etc...
``````

Then all you have to do is:

``````import arcpy
fOut = open('outputFile.txt', w)                # Open output file
fOut.write('x' + '\t' + 'y' + '\t' + 'value\n') # Write the header
rstArray = arcpy.RasterToNumPyArray(rasterFile) # Change rasterFile to numpy array
rows, cols = rstArray.shape                     # Return the rows, columns
for rowNum in xrange(rows):                     # Loop through the rows
for colNum in xrange(cols):                 # Loop through the row's columns
value = rstArray.item(rowNum, colNum)   # Get the value at the cell
fOut.write(str(rowNum) + '\t')          # Write the row number
fOut.write(str(colNum) + '\t')          # Write the column number
fOut.write(str(value) + '\n')           # Write the value and a new line
fOut.close()
``````

Note that writing to files needs to write strings. array.item() returns an actual Python data type, hence casting it into a string here. If you are running this in ArcMap, there is no need to import arcpy (the very first line).

-
Yes, If it is in python that is much better. This is exactly what I wanted. But, this will create a text file? I want is an attribute table comes with the raster dataset. –  tdr Sep 18 '12 at 20:40
The attribute table that show up in ArcMap is indeed only showing zones regardless (see Jens' reply). You can replace the '\t' with ',' to generate a CSV file which can be imported in ArcMap like any other regular table to simulate the behavior. –  Michalis Avraam Sep 18 '12 at 21:18