[GRASS-dev] g.copy with pygrass

Paulo van Breugel p.vanbreugel at gmail.com
Tue Mar 29 01:51:13 PDT 2016


Hi,

Not sure I am doing something wrong, but in pygrass the example from 
https://grasswiki.osgeo.org/wiki/Python/pygrass#Interface_to_copying_maps_.28g.copy.29 
to copy a raster doesn't work for me.

from grass.pygrass.modules.shortcuts import general as g

>>> vectinmap = 'MASK'

>>> vectoutmap = 'TMP'

>>> g.copy(raster="%s,%s" % (vectinmap,vectoutmap) )

Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/usr/local/grass7/grass-7.1.svn/etc/python/grass/pygrass/modules/interface/module.py", line 564, in __call__
     self.inputs[key].value = val
   File "/usr/local/grass7/grass-7.1.svn/etc/python/grass/pygrass/modules/interface/parameter.py", line 184, in _set_value
     self._value, self._rawvalue = _check_value(self, value)
   File "/usr/local/grass7/grass-7.1.svn/etc/python/grass/pygrass/modules/interface/parameter.py", line 66, in _check_value
     raise TypeError(msg % (param.name, param.keydescvalues))
TypeError: The Parameter <raster> require multiple inputs in the form: ('from', 'to')

However, this works:

>>> vectinmap = 'MASK'

>>> vectoutmap = 'TMP'

>>> g.copy(raster=(vectinmap,vectoutmap))

Btw, the parameter rast in the example should be raster.




More information about the grass-dev mailing list