[GRASS-dev] [bug #5167] (grass) v.patch: -a(ppend) issues

this bug's URL: http://intevation.de/rt/webrt?serial_num=5167
-------------------------------------------------------------------------

Subject: v.patch: -a(ppend) issues

Platform: GNU/Linux/x86
grass obtained from: CVS
grass binary for platform: Compiled from Sources
GRASS Version: 2006-09-23

$ v.patch -e -a input=map1 output=map2

Error: option <output>: <map2> exists.

Should v.patch in -a(ppend) mode automatically set the --ovewrite flag?

It kind-off works:

$ v.patch -e -a input=map1 output=map2 --o

But leaves the output vector in a somewhat strange state - it is OK for Grass commands (v.digit, v.info -c) but QGIS (current SVN head) complains about it that "No layers available in this map". After I v.build this vector, QGIS accepts it.

v.build helps, but it shouldn't be required. v.patch should output a valid vector. Or maybe this is QGIS fault?

What do you think Radim?

Maciek

-------------------------------------------- Managed by Request Tracker

A followup:

There are 2 more Grass commands that provide an overwrite flag that
intereferes with --o:

  r.lake:
  -o Overwrite seed map with result (lake) map

  r.mask
  -o Overwrite existing MASK

That should be fixed. As weel as the v.patch case.

In case of this one the use of -o is propably bogus - non of the
remaining Grass export modules provide an ovewrite flag:

  r.out.gridatb
  -o Overwrite output map file

The last one, but I'm not sure if the --o flag will interfere, haven't
checked:

  v.db.connect
  -o Overwrite connection parameter for certain layer

Maciek

R.mask is a shell script, so the -o flag is there to run the underlying
GRASS module with --o.

Is there a better way to do this script programmers?

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Maciej Sieczka <tutey@o2.pl>
Date: Sun, 24 Sep 2006 14:08:09 +0200
Cc: <grass-dev@grass.itc.it>
Subject: [GRASS-dev] interferring ovewrite flags [was: [bug #5167] (grass)
v.patch: -a(ppend) issues]

A followup:

There are 2 more Grass commands that provide an overwrite flag that
intereferes with --o:

r.lake:
-o Overwrite seed map with result (lake) map

r.mask
-o Overwrite existing MASK

That should be fixed. As weel as the v.patch case.

In case of this one the use of -o is propably bogus - non of the
remaining Grass export modules provide an ovewrite flag:

r.out.gridatb
-o Overwrite output map file

The last one, but I'm not sure if the --o flag will interfere, haven't
checked:

v.db.connect
-o Overwrite connection parameter for certain layer

Maciek

Michael Barton wrote:

R.mask is a shell script, so the -o flag is there to run the underlying
GRASS module with --o.

Is there a better way to do this script programmers?

r.reclass (used in r.mask) supports --o as all other Grass raster
modules do (besides r.mapcalc).

I checked r.mask and it doesn't matter whether you use it with -o or
--o. In both cases the output is ovewritten, so you just remove your -o.

Looks like parser takes care of it.

Maciek

Michael Barton wrote:

R.mask is a shell script, so the -o flag is there to run the underlying
GRASS module with --o.

Is there a better way to do this script programmers?

--o works with scripts.

If --o is present, G_parser() sets GRASS_OVERWRITE=1, which will
enable overwrite in all child processes.

--
Glynn Clements <glynn@gclements.plus.com>

Is having both -o and --o a problem?

The reason I ask is that --o, by design, doesn't show up in the
module/script GUI. For r.mask, much of the time, the user will simply want
to overwrite the existing MASK file, to avoid the annoyance of having to run
g.remove each time (note the MASK file created by r.mask is a reclass of a
real raster file, so there is little loss if it is deleted).

So in this case, I'd prefer to have an overwrite option easily accessible to
a user. How best to do this?

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Maciej Sieczka <tutey@o2.pl>
Date: Mon, 25 Sep 2006 11:53:57 +0200
To: Michael Barton <michael.barton@asu.edu>
Cc: <grass-dev@grass.itc.it>
Subject: Re: [GRASS-dev] interferring ovewrite flags [was: [bug #5167] (grass)
v.patch: -a(ppend) issues]

Michael Barton wrote:

R.mask is a shell script, so the -o flag is there to run the underlying
GRASS module with --o.

Is there a better way to do this script programmers?

r.reclass (used in r.mask) supports --o as all other Grass raster
modules do (besides r.mapcalc).

I checked r.mask and it doesn't matter whether you use it with -o or
--o. In both cases the output is ovewritten, so you just remove your -o.

Looks like parser takes care of it.

Maciek

On Mon, Sep 25, 2006 at 08:13:38AM -0700, Michael Barton wrote:

Is having both -o and --o a problem?

The reason I ask is that --o, by design, doesn't show up in the
module/script GUI.

This is a problem which should be fixed in parser.c for
both XML and tcltk. I was already asked by several users
why --overwrite doesn't show up but forgot to report it
here.

For r.mask, much of the time, the user will simply want
to overwrite the existing MASK file, to avoid the annoyance of having to run
g.remove each time (note the MASK file created by r.mask is a reclass of a
real raster file, so there is little loss if it is deleted).

So in this case, I'd prefer to have an overwrite option easily accessible to
a user. How best to do this?

The --overwrite stuff already implemented for HTML/generic needs to
be added into the XML and TclTk sections in
lib/gis/parser.c

Markus

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

> From: Maciej Sieczka <tutey@o2.pl>
> Date: Mon, 25 Sep 2006 11:53:57 +0200
> To: Michael Barton <michael.barton@asu.edu>
> Cc: <grass-dev@grass.itc.it>
> Subject: Re: [GRASS-dev] interferring ovewrite flags [was: [bug #5167] (grass)
> v.patch: -a(ppend) issues]
>
> Michael Barton wrote:
>> R.mask is a shell script, so the -o flag is there to run the underlying
>> GRASS module with --o.
>>
>> Is there a better way to do this script programmers?
>
> r.reclass (used in r.mask) supports --o as all other Grass raster
> modules do (besides r.mapcalc).
>
> I checked r.mask and it doesn't matter whether you use it with -o or
> --o. In both cases the output is ovewritten, so you just remove your -o.
>
> Looks like parser takes care of it.
>
> Maciek

_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev

--
Markus Neteler <neteler itc it> http://mpa.itc.it/markus/
ITC-irst - Centro per la Ricerca Scientifica e Tecnologica
MPBA - Predictive Models for Biol. & Environ. Data Analysis
Via Sommarive, 18 - 38050 Povo (Trento), Italy

Markus Neteler wrote:

> Is having both -o and --o a problem?
>
> The reason I ask is that --o, by design, doesn't show up in the
> module/script GUI.

This is a problem which should be fixed in parser.c for
both XML and tcltk. I was already asked by several users
why --overwrite doesn't show up but forgot to report it
here.

> For r.mask, much of the time, the user will simply want
> to overwrite the existing MASK file, to avoid the annoyance of having to run
> g.remove each time (note the MASK file created by r.mask is a reclass of a
> real raster file, so there is little loss if it is deleted).
>
> So in this case, I'd prefer to have an overwrite option easily accessible to
> a user. How best to do this?

The --overwrite stuff already implemented for HTML/generic needs to
be added into the XML and TclTk sections in
lib/gis/parser.c

It shouldn't be added to the Tcl/Tk section; as the switch is always
available in every module, it should be left to the UI to add it.

Note that it can't simply be added as if it were a normal flag due to
the double dash. Apart from that, it shouldn't be added as if it were
a normal flag due to the fact that it doesn't behave like other flags,
e.g. it cannot be composed.

There doesn't seem to be much point in adding another item type
(alongside flag and option) for the hardcoded flags.

Similar arguments apply to the XML output.

--
Glynn Clements <glynn@gclements.plus.com>

Michael Barton wrote:

Is having both -o and --o a problem?

The reason I ask is that --o, by design, doesn't show up in the
module/script GUI. For r.mask, much of the time, the user will simply
want to overwrite the existing MASK file, to avoid the annoyance of
having to run g.remove each time (note the MASK file created by r.mask
is a reclass of a real raster file, so there is little loss if it is
deleted).

So in this case, I'd prefer to have an overwrite option easily
accessible to a user. How best to do this?

be careful with using r.mask or r.mapcalc to overwrite a MASK. If the
old mask is still present when the new one is created, it will be an
additive replacement, not a full replacement. This can be very useful
for "building up" a MASK map, but also cause lots of problems if you
aren't expecting it.

I'm not exactly sure how r.reclass works (thus r.mask script too), but
it will work like this if it reads raster data row by row.

Hamish

This is interesting.

I don't *think* that r.reclass will work additively because it just makes a
new copy of the tables in cellhd and cats for the same map. I've never
noticed it when making masks.

But I haven't tested it for this specific "feature".

How can you make a mask additive with r.mapcalc? This could be useful
sometime.

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Hamish <hamish_nospam@yahoo.com>
Date: Mon, 2 Oct 2006 15:08:49 +1300
To: Michael Barton <michael.barton@asu.edu>
Cc: <tutey@o2.pl>, <grass-dev@grass.itc.it>
Subject: Re: [GRASS-dev] interferring ovewrite flags [was: [bug #5167] (grass)
v.patch: -a(ppend) issues]

Michael Barton wrote:

Is having both -o and --o a problem?

The reason I ask is that --o, by design, doesn't show up in the
module/script GUI. For r.mask, much of the time, the user will simply
want to overwrite the existing MASK file, to avoid the annoyance of
having to run g.remove each time (note the MASK file created by r.mask
is a reclass of a real raster file, so there is little loss if it is
deleted).

So in this case, I'd prefer to have an overwrite option easily
accessible to a user. How best to do this?

be careful with using r.mask or r.mapcalc to overwrite a MASK. If the
old mask is still present when the new one is created, it will be an
additive replacement, not a full replacement. This can be very useful
for "building up" a MASK map, but also cause lots of problems if you
aren't expecting it.

I'm not exactly sure how r.reclass works (thus r.mask script too), but
it will work like this if it reads raster data row by row.

Hamish