[GRASS-stats] Parameter error in when using r.horizons

Roger Bivand Roger.Bivand at nhh.no
Fri Jan 6 01:45:22 PST 2017


On Fri, 6 Jan 2017, helekua wrote:

> Hi All,
>
> I am a new GRASS user and would like to pull horizon data for multiple
> points off of a DEM.  I have been able to use the grass console to
> accomplish this but I will need to run thousands of points from a gridded
> dataset.  I was hoping to apply a function or loop in R to accomplish this
> however I am getting the following error in R while listing parameters. 
>
> Using Windows 10, R x64 3.3.2, rstudio 1.0.136 in a Grass GIS session
>
>
> *Section of code:*
> library(rgrass7)
>
> doGRASS("r.horizon", flags = c("d"), parameters = list(elevation =
> "w001001",
>                  direction = 0.0, step = 180.0,
>                  coordinates = -155.447804131,19.3115222633,


Use a numeric vector: coordinates = c(-155.447804131,19.3115222633), as 
now the comma in -155.447804131,19.3115222633 is seen as starting a new 
parameter:

> list(elevation = "w001001", direction = 0.0, step = 180.0, coordinates = 
-155.447804131,19.3115222633, file = "test_horizon1.csv")
$elevation
[1] "w001001"

$direction
[1] 0

$step
[1] 180

$coordinates
[1] -155.4478

[[5]]
[1] 19.31152

$file
[1] "test_horizon1.csv"

with the fifth list component having no name - hence the non-informative 
error message.

A more modern approach is to say:

> doGRASS("r.horizon", flags = c("d"), elevation = "w001001", direction = 
0.0, step = 180.0, coordinates = c(-155.447804131,19.3115222633), file = 
"test_horizon1.csv")
[1] "r.horizon -d elevation=w001001 direction=0 step=180 
coordinates=-155.447804131,19.3115222633 file=test_horizon1.csv"
attr(,"cmd")
[1] "r.horizon"

treating the unnamed R function arguments as GRASS parameters.

Looping over coordinates= vectors should be feasible.

Hope this helps,

Roger

>                  file = "test_horizon1.csv"))
>
> *Error:* 
> Error in doGRASS("r.horizon", flags = flags, parameters = parameters) :
>  Invalid parameter name: 
>>
>
>
>
> Any suggestions would be most appreciated.
>
> Thanks,
> Heidi
>
>
>
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/Parameter-error-in-when-using-r-horizons-tp5302223.html
> Sent from the Grass - Stats mailing list archive at Nabble.com.
> _______________________________________________
> grass-stats mailing list
> grass-stats at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-stats

-- 
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: Roger.Bivand at nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412


More information about the grass-stats mailing list