I am trying to get the X, Y coordinates of all the cells of a raster file, using Python 2.6 and ArcGIS 10.0.
I would like to get the X, Y coordinates in the center of the cell.
Is there any way to do so?
If you convert the raster to points add the X,Y fields and then use the calculate geometry function to add values to the X and Y fields.
You can use the arcpy module's GetRasterProperties command to get the xmin, xmax, ymin and ymax coordinates for the raster. By converting these values, which are returned using
To get the coordinates of every cell in the raster, you can take the raster cellsize, and use it as a step to iterate through all the values from xmin to xmax and ymin to ymax to get pass through the coordinates for each cell.
Note this code will take a long time to run with this print statement as it must print a new line for every cell in your raster.
Another method for this would be to read the convert the raster to an ASCII raster and read it into a 2D numpy array. The array indexes would then correspond to the coordinates of the cells.
|show 1 more comment|