Ticket #549 (closed defect: fixed)

Opened 9 years ago

Last modified 9 years ago

geotiff output from perl mapscript

Reported by: hunt@… Owned by: sdlime
Priority: high Milestone:
Component: MapScript Version: 4.0
Severity: normal Keywords:
Cc: sgillies@…, lfilak@…

Description

When making a geotiff from perl mapscript the geo info does not get encoded.
If I use shp2img on the same mapfile it works.

This is what Frank Warmerdam Send me on the user list.

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 );
   }

Change History

Changed 9 years ago by sgillies@…

  • cc sgillies@… added
How about changing the draw method of mapObj to store the image's
georeferencing in the resulting imageObj instance?  Give an
imageObj an "extents" attribute that is copied from the map.

This could have many uses away from GeoTIFF -- making it easy for
MapServer to output TIFFs and JPEGs with world files.

Changed 9 years ago by sgillies@…

Or, simpler yet, how about extending imageObj with a "saveGeo" or
"saveGeoreferenced" method that takes a rectObj (extent) and a
projectionObj as new arguments.  The projection would be optional,
defaulting to null. Would be used like:

mapobj.setImageType('jpeg')               # Use the built-in JPEG format
imgobj = mapobj.draw()                    # Create a JPEG image
imgobj.saveGeo('foo.jpg', mapobj.extent)  # Writes a jpg/jgw pair  

or

mapobj.setImageType('GTiff')              # use the built-in GeoTIFF format
imgobj = mapobj.draw()
imgobj.saveGeo('foo.tif', mapobj.extent, mapobj.projection)  # Writes a GTIFF

Sean



Changed 9 years ago by sdlime

  • cc warmerdam@… added

Changed 9 years ago by sgillies@…

  • status changed from new to closed
  • resolution set to fixed
Since I was in mapscript.i all afternoon, I resolved this issue.

Have added an optional mapObj argument to imageObj::save so that
it can be called like this

   imgobj = mapobj.draw()
   imgobj.save(filename, mapobj)  # will save a geo-referenced image

without breaking the current usage

   imgobj.save(filename)


Changed 9 years ago by fwarmerdam

Cool, thanks Sean.

Changed 9 years ago by hunt@…

So, is this now availableon the nightly build.

Changed 9 years ago by lfilak@…

  • cc lfilak@… added

Changed 9 years ago by sgillies@…

I committed changes to the CVS HEAD right before I marked this
issue resolved.

Note: See TracTickets for help on using tickets.