[Mapserver-users] convert pixel to world (georeferenced) coor
dinates
Antti.Roppola@brs.gov.au
Antti.Roppola@brs.gov.au
Thu, 3 Apr 2003 14:31:28 +1000
Here's a little one that I wrote for PHP/Mapscript:
function click2map ($click_x, $click_y, $current_extent) {
global $map;
$x_pct = ($click_x / $map->width);
$y_pct = 1 - ($click_y / $map->height);
$x_map = $current_extent[0] + ( ($current_extent[2] - $current_extent[0]) * $x_pct);
$y_map = $current_extent[1] + ( ($current_extent[3] - $current_extent[1]) * $y_pct);
return array($x_map, $y_map);
}
GMap has a much fancier one, but I have got by OK.
current_extent is an array of current XMin, YMin, XMax, YMax.
Cheers,
Antti
-----Original Message-----
From: Matt Doggett [mailto:mdoggett@coas.oregonstate.edu]
Sent: Thursday, 3 April 2003 11:08 AM
To: mapserver-users@lists.gis.umn.edu
Subject: [Mapserver-users] convert pixel to world (georeferenced)
coordinates
I noticed that most mapscript functions require x,y in georeferenced
coordinates. However, I also noticed there are NO functions that will
translate the img_x,img_y (pixel) coordinates that the user clicked on
the image into georeferenced coordinates. Can anyone provide pointers
on how this translation can be done?
Thanks,
Matt
Matt Doggett
Spatial Climate Analysis Service
Oregon State University
316 Strand Ag Hall
Corvallis, OR 97331
(541)737-9153
mdoggett@coas.oregonstate.edu
_______________________________________________
Mapserver-users mailing list
Mapserver-users@lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
_______________________________________________
Mapserver-users mailing list
Mapserver-users@lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users