Rasters and world files and extents, oh my!
David Badke
dbadke at UVIC.CA
Wed Feb 1 12:03:10 PST 2006
I am confused...
I have a raster image, 10540 pixels wide by 6740 pixels high, non-Geo
TIFF. The specified units in the map file are meters. I created a world
file:
1
0.0000000000
0.0000000000
-1
0.00
0.00
meaning x co-ordinates increase moving right, y coordinates decrease
moving down, from top-left pixel at x=0, y=0, with 1 pixel/meter (ie:
the raster image is 10.54 km wide by 6.74 km high, in world coordinates).
Through trial and error, with many blank output images, I found this
extent setting (in the map file) produces a correct image, generated
through a simple PHP MapScript:
EXTENT 0 -6739 10539 0
PHP is:
if (!extension_loaded('MapScript'))
dl('php_mapscript_46.'.PHP_SHLIB_SUFFIX);
$oMap = ms_newMapObj( '/ms4w/apps/kamap/htdocs/map/vicbird1878.map' );
$oImg = $oMap->draw();
$szURL = $oImg->saveWebImage();
echo "<img src=$szURL>";
While this produces the image I expect, the y coordinate is always
negative for any x, y point, which is a problem for me - and anyway, I
don't understand why miny has to be -6739. So I tried a world file like:
1
0.0000000000
0.0000000000
1
0.00
0.00
and an extent like:
EXTENT 0 0 10539 6739
thinking that both x and y coordinates would be positive and increase
from x=0, y=0 (upper left) to x=10539, y=6739 (bottom right), which is
what I want. Doesn't work - the image is blank.
So can someone explain in simple terms for the
cartographically-challenged just what the relationship is between the
world file and the extent minx, miny, maxx, maxy? If minx, miny is the
upper left pixel, and the world file says that the upper left pixel is
x=0, y=0, why doesn't EXTENT 0 0 10539 6739 refer to the entire image?
Why does a miny value of -6739 in the extent work if the top left is 0,0
and the y pixel size is -1? Sooooo confused...
David
More information about the MapServer-users
mailing list