[R-sig-Geo] Add Grid Values to Points

Alexander Brenning brenning at uwaterloo.ca
Fri Oct 31 14:33:00 CET 2008

Hi Tim,

the most recent release of RSAGA has a wrapper function for this module 
that is called rsaga.add.grid.values.to.points; try this:

rsaga.add.grid.values.to.points("test", c("slope", "aspect"),
     "add_grid", method = "nearest.neighbour", env = myenv)

(Note that the wrapper function uses default file extensions.)

The problem with your call is that multiple file names have to be passed 
to SAGA_CMD in the form
If you don't collapse the vector with semicolons, the geoprocessor will say
    GRIDS=file1.sgrd file2.sgrd file3.sgrd
and SAGA_CMD will assume that file2.sgrd is the next argument.
OK, maybe something to be changed in the next version of the 
geoprocessor, which is just a low-level workhorse.

rsaga.geoprocessor("shapes_grid", 0,
     param = list(SHAPES = "test.shp",
         GRIDS = paste(c("slope.sgrd", "aspect.sgrd"), collapse=";"),
         RESULT = "add_grid.shp", INTERPOL = 0),
     env = myenv)

I hope this helps...

Tim Häring wrote:
> Hello to everybody,
> I´m trying to use the SAGA tool "Add Grid Values to Points" in R using the RSAGA package 
> ("shapes_grid", 0) but there is an error message I can`t figure out.:
>> rsaga.geoprocessor("shapes_grid",0, list(SHAPES="test.shp", GRIDS=list("slope.sgrd", 
> "aspect.sgrd"), RESULT="add_grid.shp", INTERPOL=0), env=myenv)
> SAGA CMD 2.0.3
> library path:   C:/Programme/saga_vc/modules
> library name:   shapes_grid
> module name :   Add Grid Values to Points
> author      :   (c) 2003 by O.Conrad
> error: executing module [Add Grid Values to Points]
> Usage: -silent -SHAPES <str> -GRIDS <str> -RESULT <str> [-INTERPOL <num>]
>   -SHAPES:<str>         Points
>         Shapes (input)
>   -GRIDS:<str>          Grids
>         Grid list (input)
>   -RESULT:<str>         Result
>         Shapes (output)
>   -INTERPOL:<num>       Interpolation
>         Choice
>         Available Choices:
>         [0] Nearest Neighbor
>         [1] Bilinear Interpolation
>         [2] Inverse Distance Interpolation
>         [3] Bicubic Spline Interpolation
>         [4] B-Spline Interpolation
> 'add_grid.shp' is not a correct numeric value for option 'INTERPOL'.
> I can`t explain why R is trying to understand the expression "add_grid.shp" as the 
> Interpolationmethod even though it is previous to the INTERPOL expression in the 
> command.
> Any ideas?
> Thank`s a lot.

Alexander Brenning
brenning at uwaterloo.ca - T +1-519-888-4567 ext 35783
Department of Geography and Environmental Management
University of Waterloo
200 University Ave. W - Waterloo, ON - Canada N2L 3G1

More information about the R-sig-Geo mailing list