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

Luca Delucchi lucadeluge at gmail.com
Mon Sep 30 14:17:01 PDT 2013


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


More information about the grass-dev mailing list