MapScript and GeoTiff output

Frank Warmerdam fwarmerdam at GMAIL.COM
Tue Mar 15 02:48:54 EST 2005


On Tue, 15 Mar 2005 08:01:50 +0100, Armin Burger <armin.burger at gmx.net> wrote:
> Hi everybody,
>
> When I use the shp2img tool and select as output format 'GTiff' the tool creates a true GeoTiff, with the georeferencing and coodinates information of the map file.
>
> I would like to produce a GeoTiff output with PHP/Mapscript. I tried
>
> $mymap->selectOutputFormat("GTiff");
> $mapImg = $mymap->draw();
> $mapImg->saveWebImage();
>
> using the same mapfile as with shp2img, but the output is just a plain tiff, no georeferencing etc., just pixel coordinates. I this a bug or is just the shp2img (and maybe CGI mapserv) producing true GeoTiffs? I tried it PHP/with Mapserver 4.4 and 4.5.

Armin,

I think the problem is that the saveWebImage() call does not include the
map, and without the map, MapServer is unable to associate a
projection and extent with the file.  It looks like the saveImage() method
would do the trick, but you will need to supply an explicit filename
yourself, and also the map object used to render it (for georeferencing).

Perhaps:

 $mymap->selectOutputFormat("GTiff");
 $mapImg = $mymap->draw();
 $mapImg->saveImage("/tmp/my.tif", $mymap);

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the mapserver-users mailing list