[Mapserver-users] Geographic to Pixel Coordinates

Fraser MacLeod fraserm at terravistaltd.com
Fri Dec 19 04:00:01 EST 2003


Hi;

I have a simple map that uses a raster background to provide context for
a series of points - the map has no projection parameters. The points
appear in the correct geographical locations.

What I would like to do is create an image map (in pixel coordinates)
based on the dynamically generated set of point features. This is where
I have a problem. When I compute the pixel coordinates using the
following:

$x=round((($cur_x-$map->extent->minx)*1000)/($map->extent->maxx-$map->extent->minx));
$y=round((($map->extent->maxy-$cur_y)*690)/($map->extent->maxy-$map->extent->miny));

The size of the map that I am generating is 1000x690 pixels, and the map
extents are set at EXTENT 384000.000 664000.000 396000.000 672000.000.
My world file for registering the raster image is:

                   5.509641873000000
                   0.000000000000000
                   0.000000000000000
                  -5.617977528000000
              384002.754800000000000
              671997.191000000000000

The problem that I have is that the computed pixel coordinates do not
match the plotted point. It seems that the output image is missing a
section to the east and north of the original image.

Any suggestions?

Fraser




More information about the mapserver-users mailing list