[R-sig-Geo] execGRASS and v.mkgrid gives "Parameter <coor> does not have float value"

Roger Bivand Roger.Bivand at nhh.no
Mon Oct 1 15:29:47 CEST 2012


On Mon, 1 Oct 2012, Lars Dalby wrote:

> Hi
>
> I have tried to post this via Nabble, but apparently that did not work. 
> So I try here again. I apologise in case this leads to double posting.
>
> I have been trying to expand a vector grid using the v.mkgrid command in 
> GRASS via the execGRASS function in spgrass6. I have passed several 
> other commands via execGRASS and it has worked perfectly. However when 
> using the v.mkgrid function I get an error.
>
> I work in a location with a Behrman projection which is a cylindrical 
> equal area projection with units in meters.
>
> I call: execGRASS('v.mkgrid', parameters = list(map = 'VectorGrid', 
> position = 'coor', coor = '-6358820,-17367529', grid = '142,360', box = 
> '96486.28169014, 96486.28055556'))
>
> and get this error message:
> Error in doGRASS(cmd, flags = flags, ..., parameters = parameters, 
> echoCmd = echoCmd) :
>  Parameter <coor> does not have float value
>
> With great help from Micha at the GRASS-user list we tried to figure 
> this out and found an old bug report, that seems to be somewhat related: 
> http://trac.osgeo.org/grass/ticket/739 However the workaround suggested 
> here does not really do the trick.

No, it was three years ago.

>
> The thread I started on the GRASS-user list is here: 
> http://osgeo-org.1560.n6.nabble.com/Rasterize-polygons-multiple-polygons-per-grid-cell-td5005264.html
>
> A reproducible example and my session info is below.
> Any hints to a workaround to this problem would be highly appreciated.
>
> Thanks
> -Lars
>
> require(spgrass6)
> # Replace the path with the path to the GRASS binaries on your system
> loc <- initGRASS('/Applications/GRASS/GRASS-7.0.app/Contents/MacOS', home=tempdir(), override = TRUE)
> execGRASS('v.mkgrid', parameters = list(map = 'VectorGrid', position = 'coor', coor = '-6358820,-17367529', grid = '142,360', box = '96486.28169014, 96486.28055556'))
> # Error in doGRASS(cmd, flags = flags, ..., parameters = parameters, echoCmd = echoCmd) :
> #   Parameter <coor> does not have float value
> unlink_.gislock()
>

This works:

execGRASS('v.mkgrid', parameters = list(map = 'VectorGrid', position = 
'coor', coor = c(-6358820,-17367529), grid = c(142L,360L), box = 
c(96486.28169014, 96486.28055556)))

Note that all the parameters must be of required type, which can be 
checked with parseGRASS('v.mkgrid'), so a float vector needs c(), and 
integer values need appended L. The logic in doGRASS() now sorts out the 
oddities in the interface description of this module.

The grass-stats list may be the most appropriate for this.

Hope this clarifies,

Roger


> # sessionInfo():
> #   R version 2.15.1 (2012-06-22)
> # Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
> #
> # locale:
> # [1] C/en_US.UTF-8/C/C/C/C
> #
> # attached base packages:
> # [1] stats     graphics  grDevices utils     datasets  methods
> # [7] base
> #
> # other attached packages:
> # [1] raster_2.0-12   spgrass6_0.7-10 XML_3.9-4
> # [4] sp_0.9-99
> #
> # loaded via a namespace (and not attached):
> # [1] grid_2.15.1     lattice_0.20-10 tools_2.15.1
>
>
>
> Lars Dalby, Msc., PhD student
> E: lada at dmu.dk | T: +45 871 59013
> Department of Bioscience, Aarhus University
> Grenåvej 14, 8410 Rønde, Denmark
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no


More information about the R-sig-Geo mailing list