[Mapserver-users] mapscript and float32 geotiffs

Frank Warmerdam warmerdam at pobox.com
Sat Jun 12 12:06:34 EDT 2004


John Beisley - RSG wrote:
> Hi,
> 
> I'm trying to produce a 32-bit floating point geotiff as output from a 
> Python-Mapscript program. A similar thing used to work with the CGI 
> mapserv program with the OUTPUTFORMAT set as following:
> 
> OUTPUTFORMAT
>   NAME FGTiff
>   DRIVER "GDAL/GTiff"
>   MIMETYPE "image/tiff"
>   IMAGEMODE FLOAT32
>   EXTENSION "tif"
> END
> 
> However, I need to do a similar thing in mapscript and I run into a 
> segmentation fault. The top of the stacktrace looks like:
> #0  0x4073c39d in msImageInitGD (image=0x823f700, background=0x40d72ea4)
>    at mapgd.c:137
> #1  0x407369bc in msDrawMap (map=0x40d4a008) at mapdraw.c:142
> #2  0x406c19ea in mapObj_draw (self=0x0) at mapscript_wrap.c:2403
> #3  0x406e41ac in _wrap_mapObj_draw (self=0x0, args=0x0)
>    at mapscript_wrap.c:18792
> #4  0x080f3469 in PyCFunction_Call (func=0x405d198c, arg=0x407a7aec, 
> kw=0x0)
>    at Objects/methodobject.c:108
> 
> My code to setup the output format object is as follows:
> 
> formatObj = mapscript.outputFormatObj("GDAL/GTiff")
> formatObj.name = "fgtiff"
> formatObj.imagemode = mapscript.MS_IMAGEMODE_FLOAT32
> formatObj.mimetype = "image/tiff"
> formatObj.extension = "tif"
> mapObj.outputformat = formatObj
> 
> Any ideas why this might be happening or how to fix it?

John,

I have reproduced this problem, and determined that the mapscript methods
to set fields in the outputFormatObj are not properly resetting derived fields.
I have created a bug report to address this problem:

   http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=724

In the meantime if you explicitly set the renderer to be rawmode things see
to work.  The following worked for me (using new style names):

import mapscript

map = mapscript.Map( 'mapserver/msautotest/gdal/nodata_8bit.map' )

formatObj = mapscript.OutputFormat("GDAL/GTiff")
formatObj.name = "fgtiff"
formatObj.imagemode = mapscript.MS_IMAGEMODE_FLOAT32
formatObj.renderer = 3                   # mapscript.MS_RENDER_WITH_RAWDATA
formatObj.mimetype = "image/tiff"
formatObj.extension = "tif"
map.outputformat = formatObj

img = map.draw()

img.save( 'out.gtif' )


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