Rasters and world files and extents, oh my!

Brent Wood pcreso at PCRESO.COM
Wed Feb 1 16:48:50 EST 2006


--- David Badke <dbadke at UVIC.CA> wrote:

> I am confused...

I'm used to being in that state....

The world file contains the top left geographic coords & the offset for (or
size of) each pixel in map units. Your Y will always count down from this
value, so a world file that has the top left corner as 0,0 will have
decrementing Y's, hence negative, and increasing X's. 

If you want your image to have the bottom left corner at 0,0, then a world file
specifying a top left of 0,6740, with a per pixel Y offset of -1 will count
down the Y axis to 0 for you.

Your mapfile extent will need to recognise this, and cover from 0,0 to
10539,6739.


At least that's what I think you want to do....


Cheers,

  Brent Wood

> 
> 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