Formula for converting pixels to long lat points

Ed McNierney ed at TOPOZONE.COM
Mon Dec 6 12:35:45 PST 2004


Todd -
 
The first thing you should do is to ensure your geographic and image
extents are proportional; otherwise MapServer will be forced to adjust
your geographic extents and then you'll have to deduce what MapServer
did to change them.
 
You want to be sure that (MAXX - MINX) / WIDTH = (MAXY - MINY) / HEIGHT
so the width and height of the ground area (in degrees) are proportional
to the width and height of the image (in pixels).  In the example you
give, you want (-67 - (-125.3556)) / 449 = (49.5 - 10) / 349 (I'm
guessing on the order of the width and height).  That's not an equality,
since it computes to:

0.129968 = 0.138968

You want to change either the extents or the image size.

Once you've done that, you simply divide the width in degrees by the
width in pixels to get "degrees per pixel" or DPP: that is, DPP = (MAXX
- MINX) / WIDTH.  Then the pixel at horizontal coordinate X will have an
X-coordinate (longitude) of MINX + (X * DPP), and you do the same thing
for Y.

        - Ed

Ed McNierney
President and Chief Mapmaker
TopoZone.com / Maps a la carte, Inc.
73 Princeton Street, Suite 305
North Chelmsford, MA  01863
ed at topozone.com
(978) 251-4242 
 
 

________________________________

From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU] On
Behalf Of Todd Birkenholtz
Sent: Monday, December 06, 2004 3:22 PM
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: [UMN_MAPSERVER-USERS] Formula for converting pixels to long lat
points



Formula for converting pixels to long lat points

 

After I create a static image using the EXTENT   -125.3556 10 -67 49.5
Mapserver creates a image that is 449x349 pixels 

 

I would like to use a ismap to reference the x,y  points on my image and
then pass that information to a second web app that will convert the
pixel X,Y to  long, Lat  points.

 

I tried a couple of formulas I found in the list but I can not seam to
get it to work.

 

 

 

Thanks for your help.

 

Todd Birkenholtz  

________________________________

Do you Yahoo!?
The all-new My Yahoo! <http://my.yahoo.com>  - Get yours free! 



More information about the MapServer-users mailing list