Getting Lat/Lon from X,Y Pixel Coordinates

3424
1
03-08-2013 07:47 PM
VictorGensini1
New Contributor
I'm having difficulty calculating the latitude and longitude values of an image that I am hosting inside of a div tag on my webpage. I can easily figure out the x,y (pixel) coordinates of the image and save them to a variable inside of my script. Here's the tricky part...

The map is not a mercator projection, so I cannot simply linearly interpolate the x,y pixel coordinates to lat and lon values. However, I do have the luxury of knowing the latitude and longitude of all four corners of the image (see posted diagram), projection of the map on the image, central meridian, and latitude of origin.

[ATTACH=CONFIG]22484[/ATTACH]

The 800x600 pixel image is of the U.S. and I am basically trying to capture the latitude and longitude on click by passing the x,y pixel coordinates. I am assuming I will need some sort of transformation function.
Tags (2)
0 Kudos
1 Reply
MelitaKennedy
Esri Notable Contributor
I'm having difficulty calculating the latitude and longitude values of an image that I am hosting inside of a div tag on my webpage. I can easily figure out the x,y (pixel) coordinates of the image and save them to a variable inside of my script. Here's the tricky part...

The map is not a mercator projection, so I cannot simply linearly interpolate the x,y pixel coordinates to lat and lon values. However, I do have the luxury of knowing the latitude and longitude of all four corners of the image (see posted diagram), projection of the map on the image, central meridian, and latitude of origin.

[ATTACH=CONFIG]22484[/ATTACH]

The 800x600 pixel image is of the U.S. and I am basically trying to capture the latitude and longitude on click by passing the x,y pixel coordinates. I am assuming I will need some sort of transformation function.


Similarly to what was suggested on gis.SE, you can georeference the image. I *think* you're trying to do this outside ArcGIS software, although you can do some of these steps in ArcGIS. So, because you know the most of the projected coordinate system of the image, recalculate the corners into Stereographic (on a sphere--what sphere?), using the given parameters. At that point, you can then interpolate an individual location into the stereographic coordinates, then either implement the map projection's inverse yourself, or use proj.4 or whatever to unproject to lat/lon.


The only times you could reliably interpolate directly to lat/lon with an image that's in a projected coordinate system is if the image is very large scale and doesn't cover a large area or the map projection has square latitude/longitude 'squares'. Mercator doesn't (they elongate north-south as you move away from the equator), thus one of William Huber's comments on gis.SE. In your case, you've got a small scale map covering a large area using a map projection that definitely doesn't have square lat/lon sections.

Melita
0 Kudos