+ Reply to Thread
Results 1 to 2 of 2

Thread: Getting Lat/Lon from X,Y Pixel Coordinates

  1. #1
    Victor Gensini
    Join Date
    Mar 2013
    Posts
    1
    Points
    0
    Answers Provided
    0


    0

    Default Getting Lat/Lon from X,Y Pixel Coordinates

    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.

    Click image for larger version

Name:	pic.png
Views:	158
Size:	17.5 KB
ID:	22484

    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.

  2. #2
    Melita Kennedy

    Join Date
    Nov 2009
    Posts
    1,803
    Points
    512
    Answers Provided
    74


    0

    Default Re: Getting Lat/Lon from X,Y Pixel Coordinates

    Quote Originally Posted by vgensini View Post
    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.

    Attachment 22484

    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
    Melita Kennedy
    Sr. Esri Product Engineer

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts