Finding row and column number values of a specified pixel.

8760
3
09-27-2011 01:23 PM
EricaNewton
New Contributor
Is there any (simple) way to find the row and column number of a pixel in a raster?  Not the VALUE of the pixel, simply its location in terms of rows and columns.

Thank you!
0 Kudos
3 Replies
PatrickTaurman
Occasional Contributor III
This can be done using two methods, one of which utilizes the Field Calculator, and the second which utilizes Spatial Analyst and ArcGIS 9.3.x:

Use the following equations in the Field Calculator of the points to find columns and rows:

Int(Abs((X - ) / Z) + 1)

Int(Abs((Y - ) / Z) + 1)

Where X and Y are the starting X/Y location of the raster, and are the X/Y location of the point, and Z is the pixel size.

Please see the following example:

Int(Abs ((-80 - ) / .00083333333) + 1)

Int(Abs ((35 - ) / .00083333333) + 1)

Where -80 and 35 are the starting X/Y location of the raster, and are the X/Y location of the point, and .00083333333 is the pixel size. 

Or if you have Spatial Analyst and are using ArcGIS 9.3.x:

1. Open Single Output Map Algebra tool in Spatial Analyst tools > Map Algebra.
2. Type $$rowmap + 1 in the Map Algebra Expression window.
3. Click the Environments button and set your environments for extent and cellsize to that of the original raster.
4. Change the name of the output to Rows
5. Click OK and let the tool run.

1. Open Single Output Map Algebra tool in Spatial Analyst tools > Map Algebra.
2. Type $$colmap + 1 in the Map Algebra Expression window.
3. Click the Environments button and set your environments for extent and cellsize to that of the original raster.
4. Change the name of the output to Columns
5. Click OK and let the tool run.

1. Open the Sample tool found in Spatial Analyst Tools > Extraction.
2. Select the two rasters we created (Rows and Columns).
3. Select the point inputs.
4. Click OK and let the tool run. You will now have a table with the column and row of each point. To get the desired information in the point file attribute table, join the data together (export to a new shapefile to make it permanent).

I don't believe the second workflow will work with ArcGIS 10.

Patrick
0 Kudos
EricaNewton
New Contributor
Thanks Patrick,

I did a version your first suggestion by hand before posting, I was just hoping there was an easier way; I'm using arc 10 so your second solution may be moot.  I'm just completely flabbergasted that there isn't an easier way to do this.  I ended up exporting the file to photoshop and zooming in to use the ruler to find the approximate locations I needed.  This would be a great feature in a future version!

Thanks again for your answers!

Erica
0 Kudos
PatrickTaurman
Occasional Contributor III
Hi Erica,

A colleague of mine pointed out a couple of postings that contain information that allow this functionality at ArcGIS 10 using arcpy.

http://forums.arcgis.com/threads/18608-internal-grids-rowmap-colmap-xmap-ymap?highlight=rowmap

http://forums.arcgis.com/threads/865-quot-built-in-quot-rasters-in-python-map-algebra

The first link has a code example you might find useful, and the second link has some useful information also.

Patrick
0 Kudos