Skip to content

mapping introduction

5 messages · Paulo van Breugel, Tomislav Hengl, Stan Hopkins +1 more

#
Hi Tom,

In addition to the (very useful) earlier posts, I would like to point 
out SAGA GIS. It is a very good GIS software (and freeware / open 
source), especially for grid analyses. It has a command line version, 
which together with the ability of R to  invoke system commands using 
either 'Shell' or 'system' makes it fairly easy to do the typical GIS 
work in SAGA, and carry out other analyses in R, all from within R. With 
the recent release of the RSAGA package for R this has become 
considerably easier.

The documentation for SAGA is somewhat poor, but there are two very 
useful user guides available. See the SAGA website 
(http://www.saga-gis.uni-goettingen.de/html/index.php) for links. See 
CRAN for the RSAGA package.

Paulo
#
Dear Paulo,

I completely agree about SAGA. I have been monitoring the evolution of SAGA (or better to say of
Olaf Conrad) for quite some time. It is definitively one of the most extensive packages to analyze
DEMs, but also to do various grid computing (including geostatistics; see also my lecture notes
down-below).

I would be very much interested to see your R code-examples where you call SAGA operations. Olaf
told me that this functionality is still under construction (at least no instruction exists yet).

all the best,

Tom Hengl
http://spatial-analyst.net 

Hengl, T., 2007. A Practical Guide to Geostatistical Mapping of Environmental Variables. EUR 22904
EN Scientific and Technical Research series, Office for Official Publications of the European
Communities, Luxemburg, 143 pp.
http://eusoils.jrc.it/ESDB_Archive/eusoils_docs/other/EUR22904en.pdf 


-----Original Message-----
From: r-sig-geo-bounces at stat.math.ethz.ch [mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of
Paulo van Breugel
Sent: maandag 26 november 2007 12:55
To: tomfool at as220.org
Cc: r-sig-geo at stat.math.ethz.ch
Subject: Re: [R-sig-Geo] mapping introduction

Hi Tom,

In addition to the (very useful) earlier posts, I would like to point 
out SAGA GIS. It is a very good GIS software (and freeware / open 
source), especially for grid analyses. It has a command line version, 
which together with the ability of R to  invoke system commands using 
either 'Shell' or 'system' makes it fairly easy to do the typical GIS 
work in SAGA, and carry out other analyses in R, all from within R. With 
the recent release of the RSAGA package for R this has become 
considerably easier.

The documentation for SAGA is somewhat poor, but there are two very 
useful user guides available. See the SAGA website 
(http://www.saga-gis.uni-goettingen.de/html/index.php) for links. See 
CRAN for the RSAGA package.

Paulo

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
#
I was just about ready to option out of this sig group as being too when the 
last few of questions and answers were posted perhaps by beginners like 
myself.

I wonder if there's any way to separate newbie questions from the more 
advanced so that my mailbox isn't flooded with the later.

Thanks,

Stan

----- Original Message ----- 
From: "Tomislav Hengl" <hengl at science.uva.nl>
To: "'Paulo van Breugel'" <p.vanbreugel at gmail.com>; <tomfool at as220.org>
Cc: <r-sig-geo at stat.math.ethz.ch>
Sent: Monday, November 26, 2007 9:57 AM
Subject: Re: [R-sig-Geo] mapping introduction
#
On Mon, 26 Nov 2007, Stan Hopkins wrote:

            
This has been asked on the R-help list several times, with the general 
result that the current mixture of less and more experienced users being 
more beneficial for both than any alternative. The R wiki is also 
well-nigh moribund, for the same reasons (briefly that some posts by 
users with less experience are really high quality - point up a real 
issue, and attract the attention of more experienced users.

So the differences in experience are seen as a good thing for the R 
project as a whole. Very little of the traffic on this list is as 
difficult as R-devel, which involved system changes and compiled code, and 
much good advice offered here is contributed by users who, until recently, 
would have fell that they did not have much experience (at least with 
R-like things).

The R lists can be subscribed to in digest mode, and can be accessed via 
nabble and gmane too. So there are options. Offers to contribute new text 
to the Rgeo site and to the Spatial Task View will be welcomed - there is 
room for improvement in both that I'm aware of but cannot carry out for 
lack of time - any offers?

Thank you for your patience so far! One of the best kinds of contribution 
that can be made is good comments and questions!

Roger

  
    
#
Dear Tom,

Thanks for the lecture notes, very interesting. I don't use the 
combination R - SAGA for the more advanced geostatistics you're 
describing, but rather to access more basic GIS modules such as the grid 
calculator and resample modules. But I don't see any reason why you 
couldn't use it for the other modules too.

I would recommend to have a look at the RSAGA package. It makes it 
easier to use SAGA. Moreover, it offers extended functionality, which, 
and I quote from the package help file, "include specific functions that 
are intended to be more user-friendly interfaces to the most frequently 
used SAGA modules. These higher-level interfaces support default values 
for the arguments and perform some error checking".

For those modules for which there is no direct interface (most), there 
is a low-level function (rsaga.geoprocessor) that can be used to run any 
SAGA modules and pass arguments. The interface is slightly different 
than when using the command line directly, see the RSAGA documentation 
for that. I just started using RSAGA so maybe you can also contact the 
author of the RSAGA package or use the SAGA user to user forum for more 
information.

Whether you use RSAGA or not, finding out the syntax of the different 
modules is probably the most complicated step because of missing 
documentation. For those interested, I normally use the following steps 
to figure out the arguments to a function (no R involved yet). I assume 
here you know which module you want to use; in this example I want to 
use the grid calculator to multiply grid 'inputA.sgrd' with grid 
'inputB.sgrd'

1) Before you run any command, you have to set the SAGA path, module 
path and data (working) directory, using the following commands (when 
you use RSAGA in R, this is easier):

 > cd c:\\program files\\saga_vc
 > set SAGA=.
 > SET SAGA_MLB=./modules
 > PATH=PATH;%SAGA%;%SAGA_MLB%

2) To find out which module library to call, you can select the module 
library that contains your module in the SAGA GUI (grid-calculus in this 
case) and than the description tab in the object properties window for 
the name of the dll (grid_calculus.dll).

3) Go back to the command line window and type in:

 > saga_cmd grid_calculus

4) You will be presented with a list of modules. Find the one you want 
to use. The grid calculator is module 1.

 > saga_cmd grid_calculus 1

5) you will be presented with the required syntax options. In my 
example, I'll need to give the names of the input and output layers and 
the equation:

 > saga_cmd grid_calculus 1 -INPUT inputA.sgrd;inputB.sgrd -RESULT 
output.sgrd -FORMUL a*b

 From within R, using the RSAGA package, you would use the following code:

rsaga.geoprocessor("grid_calculus", module=1, param=list(INPUT 
="inputA.sgrd;inputB.sgrd", RESULT=output.sgrd, FORMUL= 'a*b')

---
Below a small example of some real (but simple) code I used to resample 
grids to a certain extent and resolution. I wrote it as a function 
because I had to resample many grids to the same extent and resolution.

resample.SAGA <- function(sgrd.in, sgrd.out=sgrd, column=4294, 
rows=5415, east=12.210798, south=-13.451510, cell.size=0.008333, 
up.scale=0, down.scale=0){
options(digits=15)
rsaga.geoprocessor("grid_tools", module=0, param=list(INPUT=sgrd.in, 
GRID=sgrd.out, METHOD=1, KEEP_TYPE="", SYSTEM_SYSTEM_NX=column, 
SYSTEM_SYSTEM_NY=rows, SYSTEM_SYSTEM_X=east, SYSTEM_SYSTEM_Y=south, 
SYSTEM_SYSTEM_D=cell.size, SCALE_DOWN_METHOD=up.scale, 
SCALE_UP_METHOD=down.scale))}

---
In the following example I use the 'change grid values' module to change 
the grid values of a raster. The lookup table 'change.clim', with the 
mandatory three columns "Low Value", "High Value", and "Replace with", 
was generated in R:

library(foreign); library(RSAGA)
write.dbf(change.clim, "c:\\temp\\change_clim.dbf")
rsaga.geoprocessor("grid_tools", module=12, 
param=list(GRID_IN=c:\\temp\\clim.sgrd, GRID_OUT=c:\\temp\\climzon, 
METHOD=0, LOOKUP= c:\\temp\\chang_clim.dbf)
shell("del c:\\temp\\change_clim.dbf")

These are very simple examples, but hopefully they are useful nonetheless.

Paulo
Tomislav Hengl wrote:

        
Tomislav Hengl wrote: