Introducing Geoprocessing Capabilities of SAGA in R Environment using RSAGA (Saga + Rstudio)

From CUOSGwiki
Jump to navigationJump to search

Purpose

This Wikipage has been created for GEOM4008 Class - Advanced Topics in Geographic Information Systems class at Carleton University. The main purpose of this tutorial is to introduce and familiarize future users to understand the computing geoprocessing commands in the R environment and while utilizing the SAGA-GIS platform. In this particular tutorial we will be attempting to work with Terrain Analysis modules on our area of interest - The Gatineau Park located in Quebec, Canada.

Objective

The objective of this tutorial is to establish an understanding of the geoprocessing tools available by calling functions from the interface between Rstudio and SAGA (RSAGA) using R scripts.

Software Introduction

Rstudio

RStudio-Logo.png


This is an open software program that creates a user-friendly graphic user interface for accessing the R statistical analysis and scripting language. R is often used for data analysis, statistics and graphing of very large datasets. It also has the ability to interface with the SAGA spatial analysis program, through the 69 modules shown below; users are able to use spatial data and manipulate and perform geoprocessing via special commands within this software. The more you explore and use the commands the more comfortable you will get. Initially everyone may face difficulty, however, if the basics are understood well, it eases major geoprocessing tools. R studio is known for handling large datasets with efficiency and helps in optimizing results quicker in order to perform them multiple times at a time without the needs to run through the steps again and again. Also, R not only processes data but if users may want to visualize their spatial output of their data, R has a package called sp which has that feature.

To download RStudio click the link --> https://www.rstudio.com/products/rstudio/download/

Saga

Saga-logo.png


System for Automated Geoscientific Analyses - is a Geographic Information System (GIS) software with immense capabilities for geodata processing and analysis. Functions are organised as modules in framework independent Module Libraries and can be accessed via SAGA’s Graphical User Interface (GUI) or various scripting environments such python or Rstudio.

To download Saga-Gis software Click this link -- > http://sourceforge.net/projects/saga-gis/

Data Setup

DEM

ORIGINAL DEM.jpeg
Figure 1. Original DEM- Gatineau Park, Quebec

The above DEM of Gatineau Parking Located in Quebec, Canada is our area of interest for this tutorial. The specifications of this DEM - it is a 5 meter DEM which hold to be best for visualizing terrain.It also is very useful when trying out 3D representation of a terrain's surface. Therefore, the user may consider going as far as 10 meter however, it is recommended the smaller the better for accuracy and interpretation.


Note : The user is welcome to explore other datasets to work on this tutorial.

Free open data can be downloaded---> from http://geogratis.gc.ca/geogratis/en/search


Canada Regional Data Wesbites

GeoDiscover Alberta Portal || Alberta regional GIS datasets on a variety of topics hosted by the Alberta Government.

DataBC Data Catalogue || Spatial and aspatial data from the province of British Columbia.

Land Information Ontario || Spatial data from the province of Ontario.

Manitoba Land Initiative || Spatial data from the province of Manitoba.

Date Usage

Permission & Licence Agreement Form

Please follow the step below in order to access the data or be able to use it

1) To use the same data as shown in this tutorial the user would need to be from Carleton university and currently enrolled in a program.


2) They need to sign GIS Data Use Agreement prior to use, which is compliant with our data license with the NCC. To share the data otherwise (even between students) would contravene the license.


3) For any other support Rebecca Bartlett is GIS and Digital Resources Librarian who could provide further assistance to Carleton students.


4) It is very important the user understands the legal considerations behind using the 5 m DEM of Gatineau Park.


5) Lastly, if any user who could be categorized as a non-Carleton student, would need to directly ask the NCC for further data permissions.

How to Sign the Agreement

Go to - https://library.carleton.ca/find/gis ( copy and paste link in URL)


To the righthand side of the website

Data agreement usage website.png


Figure 2. GIS Potal on Carleton University website'

User needs to sign in with their Carleton username and password

Agreement sign.png
Figure 3. User Login

Understanding Basic R Environment

To begin this tutorial, the author understands or predicts the user has prior knowledge or understanding of how Rstudio commands and environment setup works.

However, if the user feels they are not familiar they are welcome to check an introductory tutorial below in the link by Julia Riddick.

http://gracilis.carleton.ca/CUOSGwiki/index.php/R_Studio%27s_Spatial_Capabilities

Rsaga Tutorial

Just a quick sneak into how everything works in Rstudio

Rstudio Envrionment Setup

RStudioEnvrioment.png


An example of data importing window from Rsutdio

ImportingSet.png


Before we being the tutorial we need to prepare both the software so there is a connection between them. As you already know the core of this tutorial is to teach the user on how geoprocessing of SAGA performs in R using its Environment via scripting.

How to Set Up RSAGA

StepR1.png SettingR.png

Figure 4. Set Working Directory Preview


StepR2.png



UserR.JPG

System1Library.png

Figure 5. The two image above shows packages which should be checked marked from 'User Library'



StepR3.png

StepR4.png


SettingEnv.JPG
Figure 6. Finding out the Saga File path.


StepR5.png

Note: If the user wishes to understand on how to import a raster into Saga you are welcome to follow the Tutorial produced by Taylor McWade in section "Importing Data" - Just click the link below

http://gracilis.carleton.ca/CUOSGwiki/index.php/Exploring_a_subset_of_SAGA%27s_Terrain_Analysis_tools


StepR6.png


71.JPG


Figure 7. The above images shows a list of 71 modules from the Rpackage library


StepR7.png


GEO1.JPG GEO2.JPG centre right

Figure 8 The above image shows all the tools within Morphometry, Hydrology and lighting.


StepR8.png


StepR9.png


Note: If none of these two above step work and result in error, you might want to check your command setup again, it usually varies between the users computer setup. However,it is ok you can still proceed to next step. The earlier library command in Step 3 should do the work to call out all modules.

GeoProcessing Using Rsaga

Multi Geoprocess R Command Script

MultiR.png


Slope

StepR10.png


Result :

RSlope.png
Figure 9.Slope

Just some options you can use from below :

  1. Maximum Slope - Travis et al. (1975) ("maxslope", or 0)
  2. Max. Triangle Slope - Tarboton (1997) ("maxtriangleslope", or 1)
  3. Least Squares Fit Plane - Costa-Cabral and Burgess (1996) ("lsqfitplane", or 2)
  4. Fit 2nd Degree Polynomial - Bauer et al. (1985) ("poly2bauer", or 3)
  5. Fit 2nd Degree Polynomial - Heerdegen and Beran (1982) ("poly2heerdegen", or 4)
  6. Default: Fit 2nd Degree Polynomial - Zevenbergen and Thorne (1987) ("poly2zevenbergen", or 5)
  7. Fit 3rd Degree Polynomial - Haralick (1983) ("poly3haralick", or 6).

In this tutorial the default option was choosen : poly2zevenbergen for slope and later then Max slope was attempted as seen above in my R command script

Aspect

AspectR.png

Result:


RAspect.png
Figure 10.Aspect
Profile & Plan Curvature

Rcurvature.png


Result :

RPlanCurvature .png

ProfileCurvature.PNG


Figure 11a. Plan Curvature
Figure 11b. Profile Curvature
Wet index

WetIndexR.png


Result:

RWetindex.png



Figure 12. Saga Wetness Index
Analytical Hillshading

HillShading.png



RHillshade.JPG


Figure13. Analytical HillShading






NOTE : The usual setup for SAGA geoprocessing environment as created by rsaga.env for further arguments to rsaga.geoprocessor in this tutorial we have rsaga.env as env = env

Conclusion

In conclusion, both software packages successfully got connected which is the first and most important step of this RSAGA tutorial. Once that has been setup, having the knowledge of R commands can be useful to perform many other geoprocessing tools using different modules, depending on the goal and the type of data the user might have. This tutorial would definitely help users who plan to work with large data sets. As Rstudio being a very powerful software - RSAGA package within that manages to perform many geoprocessing on large datasets much quickly, saving users time and it's free of cost. The feasibility and commonality of R scripting makes it much more encouraging and persuasive for users with both python scripting background or no coding background to get started. This tutorial definitely fills the gap of sharing a quick step by step knowledge base for future users or Carleton students to perform their geoprocessing tasks much efficiently.

Refrences

1) Basin, Kuya River. Digital Elevation Model Is A Tool For Terrain Analysis: Implication And Interpretation. 1st ed. West Bengal: International Journal of Engineering Science and Innovative Technology, 2015. Web. 7 Dec. 2015.

http://www.ijesit.com/Volume%202/Issue%201/IJESIT201301_38.pdf


2)Brenning, Alexander and, and Donovan Bangs. SAGA Geoprocessing And Terrain Analysis In R. 1st ed. Alexander Brenning and Donovan Bangs, 2015. Web. 17 Dec. 2015.

https://cran.r-project.org/web/packages/RSAGA/RSAGA.pdf


3) Brenning, Alexander, and Donovan Bangs. Introduction To Terrain Analysis With RSAGA: Landslide Susceptibility Modeling. 1st ed. DFG-FOR816dw, 2015. Web. 15 Dec. 2015.

https://cran.r-project.org/web/packages/RSAGA/vignettes/RSAGA-landslides.pdf


4) Conrad, O. et al. "System For Automated Geoscientific Analyses (SAGA) V. 2.1.4". Geoscientific Model Development 8.7 (2015): 1991-2007. Web. 15 Dec. 2015.

http://sourceforge.net/projects/saga-gis/


5) University, Colorado. GIS Modeling - Class 6: Terrain Analysis. 1st ed. Colorado University, 2008. Web. 12 Dec. 2015.

http://www.colorado.edu/geography/class_homepages/geog_4203_s08/class6_TerrainAnSlopeAspect.pdf