Monday 10 April 2017

python - Using Mapscript to create a mapfile from scratch


Following a few online tutorials I have seen, I am trying to create a mapfile from scratch using mapscript. However, when I try to create the layer object, I get an error in the init of mapscript.py; NameError: global name 'args' is not defined.


Does anyone see something obvious? When I use a mapfile that already exists on disk, everything works as expected.


        # create a new mapfile from scratch
self.map = mapscript.mapObj()
self.map.save('temp.map')
self.map.setSize(256,256)
self.map.setExtent(-180.0,-90.0,180.0,90.0)
self.map.units= mapscript.MS_DD
self.map.imagecolor.setRGB(255,255,255)


# create a layer for the raster
self.layer = mapscript.layerObj(self.map) ----> ERROR HAPPENS HERE
self.layer.name= 'tilesource'
self.layer.type= mapscript.MS_RASTER
self.layer.status = mapscript.MS_ON
self.layer.data= rasterpath


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...