[Mapserver-dev] Re: [Mapserver-users] geotiff output problem

Frank Warmerdam warmerdam at pobox.com
Wed Jan 28 11:16:59 EST 2004

Aaron D. Hunt wrote:
> The perl and mapfile are bellow.
> Perl
> #!/usr/bin/perl
> use lib("/home/mapserver");
> use mapscript40;
> $ENV{MS_ERRORFILE} = "mapserver.log";
> $ENV{PROJ_LIB} = "/home/mapserver/proj-4.4.7/nad/";
> my $map = new mapscript40::mapObj("geotif.map") or die("Unable to open
> mapfile. $!");
> $img = $map->draw() or die('Unable to draw map');
> $imagename = "test.tiff";
> $img->save($imagename);


OK, the above $img->save($imagename) is the problem.  The underlying C
function is looks like this:

int msSaveImage(mapObj *map, imageObj *img, char *filename)

In the GDAL fork, it checks if map is NULL.  If it is NULL no coordinates
or georeferencing system is saved (because it gets it from the map).  That
is why your getting a plain TIFF instead of a GeoTIFF.

Looking through mapscript.i, I see that there is a save() method on the
imageObj, but it just passed NULL to msSaveImage() for the map.  There
does not seem to be a save operation that includes the map handle accessable
in MapScript.

My suggestion is that you file an enhancement request in bugzilla requesting
one, and explaining why you need it.  I would suggest it be implemented
something like the following as a method on the mapObj.

   void saveImage(imageObj *image, char *filename) {

     msSaveImage(self, image, filename );

If you are a bit brave, you might want to incorporate this into your version
and rebuild to test.

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-dev mailing list