Re: [R-sig-Geo] GRASS commands (fwd)

3 messages Options
Embed this post
Permalink
Roger Bivand

Re: [R-sig-Geo] GRASS commands (fwd)

Reply Threaded More More options
Print post
Permalink
Is this a bug in the interface description of v.mkgrid? It needs
grid=rows,columns but sets multiple=NO, so wxpython fails (needing two
values but getting one, but only providing an integer entry box).

Roger

--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [hidden email]


---------- Forwarded message ----------
Date: Tue, 1 Sep 2009 14:40:13 +0200 (CEST)
From: Roger Bivand <[hidden email]>
To: Alexandre VILLERS <[hidden email]>
Cc: Aide R SIG GEO <[hidden email]>
Subject: Re: [R-sig-Geo] GRASS commands

On Tue, 1 Sep 2009, Alexandre VILLERS wrote:

> Goord morning,
>
> I would like to use v.mkgrid (with spgrass6) and I need to specify box and
> grid parameters, which both require 2 values box=5000,5000 grid=1000,1000
> How do I specify this in my parameters list ?
> parseGRASS6("v.mkgrid") returns
> Command: v.mkgrid
> Extension: .exe
> Description: Creates a GRASS vector map of a user-defined grid.
> Keywords: vector
> Parameters:
>   name: map, type: string, required: yes, multiple: no
>  [Name for output vector map]
>   name: grid, type: integer, required: yes, multiple: no
>  [Number of rows and columns in grid]
>   name: position, type: string, required: no, multiple: no
>  [Where to place the grid]
>   name: coor, type: float, required: no, multiple: no
>  [Lower left easting and northing coordinates of map]
>   name: box, type: float, required: no, multiple: no
>  [Width and height of boxes in grid]
>   name: angle, type: float, required: no, multiple: no
>  [Angle of rotation (in degrees counter-clockwise)]
> Flags:
>   name: q [Quiet; No chatter]
>   name: overwrite [Allow output files to overwrite existing files]
>   name: verbose [Verbose module output]
>   name: quiet [Quiet module output]
>
> execGRASS("v.mkgrid", flags="overwrite",
parameters=list(map="grilleTest",
> grid=c(as.integer(100),as.integer(100)), box=c(5000, 5000),
> position="region"))
> returns
> Erreur dans doGRASS(cmd, flags = flags, parameters = parameters) :
>   Parameter <grid> has multiple values
>
> How do I specify the two values when multiple is not allowed. I did not get
> it....

Consider the statsgrass list for use of the interface between R and GRASS, in
this case there is an interaction between a possible bug in v.mkgrid and the
parsing of its parameters.

Since v.mkgrid does declare that grid does *not* take multiple values, the
(current) logic of doGRASS() is defeated, as it checks that the multiple
attribute if the GRASS parameter is not "NO", see

http://trac.osgeo.org/grass/browser/grass/trunk/vector/v.mkgrid/main.c#L74

The discrepancy between the code and the documentation is obvious.

Please ask on a GRASS list whether other scripted interfaces experience the
same problem - as far as I can see from the wxpython interface, only a single
value is accepted, but running the command fails because two are required (same
problem in reverse). Thw widget used for entering the parameter values does not
the entry of two values. The work-around for now is to use v.mkgrid in system()
directly.

Hope this helps,

Roger

>
> Thanks
>
>

--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [hidden email]
_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
Economic Geography Section
Department of Economics
Norwegian School of Economics and Business Administration
Helleveien 30
N-5045 Bergen, Norway
Markus Neteler-2-2

Re: Re: [R-sig-Geo] GRASS commands (fwd)

Reply Threaded More More options
Print post
Permalink
2009/9/1 Roger Bivand <[hidden email]>:
 > Is this a bug in the interface description of v.mkgrid? It needs
 > grid=rows,columns but sets multiple=NO, so wxpython fails (needing two
 > values but getting one, but only providing an integer entry box).

It needs two values which are treated as one string, so it is correct.
(E.g. r.series accepts multiple input maps which are separate tokens which
required multiple=YES).

...
 >> grid=c(as.integer(100),as.integer(100)), box=c(5000, 5000),
 >> position="region"))
 >> returns
 >> Erreur dans doGRASS(cmd, flags = flags, parameters = parameters) :
 >>   Parameter <grid> has multiple values
 >>
 >> How do I specify the two values when multiple is not allowed. I did not
 >> get it....

You used
 > c(as.integer(100),as.integer(100))
[1] 100 100

 > c(5000, 5000)
[1] 5000 5000

which leads to space separated values. But we want

 > paste(as.integer(100), as.integer(100), sep=",")
[1] "100,100"

 > Consider the statsgrass list for use of the interface between R and
GRASS,
 > in this case there is an interaction between a possible bug in
v.mkgrid and
 > the parsing of its parameters.
 >
 > Since v.mkgrid does declare that grid does *not* take multiple
values, the
 > (current) logic of doGRASS() is defeated, as it checks that the multiple
 > attribute if the GRASS parameter is not "NO", see
 >
 >
http://trac.osgeo.org/grass/browser/grass/trunk/vector/v.mkgrid/main.c#L74
 >
 > The discrepancy between the code and the documentation is obvious.

There is no real discrepancy...
Hope above comments clarify it.

If not, we would need to see some debug output of doGRASS()...

Markus

--
Markus Neteler
Foundation Edmund Mach (FEM) - Research and Innovation Centre
Environment and Natural Resources Area
GIS and Remote Sensing Unit, Trento, Italy
Web:  http://gis.fem-environment.eu/

_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand

Re: Re: Re: [R-sig-Geo] GRASS commands (fwd)

Reply Threaded More More options
Print post
Permalink
In reply to this post by Roger Bivand
On Tue, 1 Sep 2009, alexandre villers wrote:

> Good evening,
>
> Thank you for the message. I had already tried this but then got the error message:
>
> execGRASS("v.mkgrid", flags="overwrite", parameters=list(map="grilleTest", grid=paste(as.integer(100), as.integer(100), sep=","), box=paste(as.integer(5000),",",as.integer(5000),sep=""), position="region")) #créer une grille de box1 mètres sur box2 mètres sur la région   !!! PB WITH the double argument required for box and grid).
> Erreur dans doGRASS(cmd, flags = flags, parameters = parameters) :
>  Parameter <grid> does not have integer value

I've submitted a new version of spgrass6 to CRAN that handles the
ambiguity inherent in the multiple=no and a keydesc count of greater than
1. When it gets through, please try. If you like, check out the source
from r-spatial on sourceforge. I'd be interested to know whether this also
resolves your earlier r.neighbors problem.

Roger

>
> Does this make sense to you ? v.mkgrid is asking for an integer but the paste() has turned integer into character... and list of the 2 integers is also rejected because of the "multiple = NO" argument...
>
> I'm afraid I can't go further...
>
> Best regards
>
> Alex
>
> -----Original Message-----
> From: Markus Neteler <[hidden email]>
> To: [hidden email]
> Date: Tue, 01 Sep 2009 22:22:49 +0200
> Subject: Re: [GRASS-stats] Re: [R-sig-Geo] GRASS commands (fwd)
>
> 2009/9/1 Roger Bivand <[hidden email]>:
> > Is this a bug in the interface description of v.mkgrid? It needs
> > grid=rows,columns but sets multiple=NO, so wxpython fails (needing two
> > values but getting one, but only providing an integer entry box).
>
> It needs two values which are treated as one string, so it is correct.
> (E.g. r.series accepts multiple input maps which are separate tokens which
> required multiple=YES).
>
> ...
> >> grid=c(as.integer(100),as.integer(100)), box=c(5000, 5000),
> >> position="region"))
> >> returns
> >> Erreur dans doGRASS(cmd, flags = flags, parameters = parameters) :
> >>   Parameter <grid> has multiple values
> >>
> >> How do I specify the two values when multiple is not allowed. I did not
> >> get it....
>
> You used
> > c(as.integer(100),as.integer(100))
> [1] 100 100
>
> > c(5000, 5000)
> [1] 5000 5000
>
> which leads to space separated values. But we want
>
> > paste(as.integer(100), as.integer(100), sep=",")
> [1] "100,100"
>
> > Consider the statsgrass list for use of the interface between R and
> GRASS,
> > in this case there is an interaction between a possible bug in
> v.mkgrid and
> > the parsing of its parameters.
> >
> > Since v.mkgrid does declare that grid does *not* take multiple
> values, the
> > (current) logic of doGRASS() is defeated, as it checks that the multiple
> > attribute if the GRASS parameter is not "NO", see
> >
> >
> http://trac.osgeo.org/grass/browser/grass/trunk/vector/v.mkgrid/main.c#L74
> >
> > The discrepancy between the code and the documentation is obvious.
>
> There is no real discrepancy...
> Hope above comments clarify it.
>
> If not, we would need to see some debug output of doGRASS()...
>
> Markus
>
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [hidden email]

_______________________________________________
grass-stats mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-stats
Roger Bivand
Economic Geography Section
Department of Economics
Norwegian School of Economics and Business Administration
Helleveien 30
N-5045 Bergen, Norway