Formula for converting pixels to long lat points
Abe Gillespie
agillesp at VT.EDU
Mon Dec 6 13:09:34 PST 2004
I don't mean to be a jerk, but it should be simple algebra to solve for
the variables you want.
-Abe
On Dec 6, 2004, at 3:41 PM, Joseph Norris wrote:
> What about a formula for doing the reverse - I have lat/long and I
> want to
> pixel position within an image. Thanks
>
> #Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql) print
> @c=map chr
> $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,-68,4,-3,
> -1,7,1,14,-
> 68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);
>
> -----Original Message-----
> From: UMN MapServer Users List [mailto:MAPSERVER-USERS at lists.umn.edu]On
> Behalf Of Ed McNierney
> Sent: Monday, December 06, 2004 12:36 PM
> To: MAPSERVER-USERS at lists.umn.edu
> Subject: Re: [UMN_MAPSERVER-USERS] Formula for converting pixels to
> long lat
> points
>
> 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