Select to view content in your preferred language

Extract image x,y from lat long coordinates?

3376
3
10-22-2012 12:25 PM
DavidMedeiros
Frequent Contributor
I have some geo referenced images that I need to extract a series of pixel values for at specific lat/long locations (that part is easy). I also need to extract the image x and y for each of these pixels and I don't see any way to do that in Arc.

Any suggestions for getting the image xy (not the map xy) from an image layer based on input coordinates or points?

Thanks,
David
0 Kudos
3 Replies
JamieDrisdelle
Occasional Contributor
Hi David,

If you want to extract the actual pixel value and place it into an attribute table of a point feature class you can use the extract values to points tool in the spatial analyst extraction tool set.  If you actually want to clip the raster to a point feature class and essentially end up with a raster that contains a single pixel under each point you can use the extract by mask tool in the spatial analyst extraction tool set.



Jamie
0 Kudos
DavidMedeiros
Frequent Contributor
I actually do know how to extract values to points. What I am after is the corresponding image x/y coordinates (pixel xy in the image, not geographic xy), that go with the lat/long points. The student I'm working with needs the image xy to use in a separate script he's written that analyzes the pixel values for cloud cover and radiance at specified locations. It's not a GIS script so it just needs image coordinates for the pixels.

I think I have a workaround but would still like to know if Arc can determine the image coordinates of a point over the image.
0 Kudos
JamieDrisdelle
Occasional Contributor
Hi David,

You can do this in ArcGIS but it would require you to use Python.  The method you would want to use is RasterToNumPyArray.  Once you convert your raster to an array you can query it using numpy in Python.  Here is a basic code sample.

import numpy
import arcpy

myArray = arcpy.RasterToNumPyArray('C:/data/inRaster')
pixelvalue = myArray[1,0]

print pixelvalue


The first value in the array will start at 0,0.

I hope this helps.

Jamie
0 Kudos