[GRASS-dev] Overwrite flag in Grass70 python scripts with grass.script.array array ?

Johannes Radinger johannesradinger at gmail.com
Tue Oct 1 02:55:59 PDT 2013


Thank you Luca,

the problem was that in the options settings the parameter gisprompt for
the output did not contain "new". After changing the line to gispromt: new,
the overwrite option was available.
Thank you for the tip with the "grass.overwrite()" which returns TRUE if
overwrite is set.

/Johannes


On Mon, Sep 30, 2013 at 11:17 PM, Luca Delucchi <lucadeluge at gmail.com>wrote:

> On 30 September 2013 17:10, Johannes Radinger
> <johannesradinger at gmail.com> wrote:
> > Hi,
> >
>
> Hi
>
> > when I tried to write a python script (add-on) for GRASS GIS I
> experienced
> > that there is no overwrite-flag by default in the GUI for that module
> > (generate by
> > g.parser) which is different from GRASS6x. So is there any possibility to
> > create
> > that tick-box also in G70?
> > Furthermore I am using the grass.script.array to write a raster map from
> > a numpy.array:
> >
> > my_map = garray.array()
> > my_map[...] = my_function_mod(input_raster)
> > my_map.write(options['my_output'])
> >
> > But what if the output ("my_output") already exists and I want to
> overwrite
> > that output (e.g. by setting the modules overwrite flag)?
> >
>
> overwrite flag should be in the parser, you have to check if overwrite
> is active and if your map already exits.
> You can check if the overwrite is active with "grass.overwrite()"
>
> > Any suggestions are welcome, thanks!
> >
> > cheers,
> > /Johannes
> >
>
> --
> ciao
> Luca
>
> http://gis.cri.fmach.it/delucchi/
> www.lucadelu.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20131001/3f5329b7/attachment.html>


More information about the grass-dev mailing list