Difference between revisions of "Introducing Geoprocessing Capabilities of SAGA in R Environment using RSAGA (Saga + Rstudio)"

From CUOSGwiki
Jump to navigationJump to search
Line 219: Line 219:
   
 
=====Analytical Hillshading=====
 
=====Analytical Hillshading=====
  +
  +
  +
  +
  +
  +
[[File:HillShading.png|1000px|]]
  +
  +
  +
  +
  +
[[File:RHillshade.JPG|600px|centre]]
  +
  +
  +
<div align="center">Figure13. Analytical HillShading.''</div>
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
  +
'''NOTE : setting up a SAGA geoprocessing environment as created by rsaga.env for further arguments to rsaga.geoprocessor in this case we have rsaga.env as env = env '''
   
 
==Original R Script ==
 
==Original R Script ==

Revision as of 03:24, 20 December 2015

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 Ontario, Canada.

Objective

The objective of this tutorial would be to establish an understanding of using the geoprocessing tools by calling functions out between Rstudio and SAGA - RSAGA using R scripted commands.

Softwares Introduction

Rstudio

RStudio-Logo.png


This is an open software program deals with its own scripting language that is often used for data analysis, statistics and graphing of very large datasets. It also has the power to perform 69 modules as seen below, users are able to use spatial data such as DEM or Excel files to 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 feels the 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.

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.

Data Setup

DEM

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

The above DEM of Gatineau Parking Located in Ontario, 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.

Date Usage

Permission & Licence Agreement From

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 considering behind using the 5mDEM 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

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.

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


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

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 & Plain Curvature

Rcurvature.png


Result :

RPlanCurvature .png

ProfileCurvature.PNG


Figure 11a. Plain Curvature
Figure 11b. Profile Curvature

Multi Geoprocess R Command Script

MultiR.png


Wet index

WetIndexR.png


Result:

RWetindex.png



Figure 12. Saga Wetness Index
Analytical Hillshading

HillShading.png



RHillshade.JPG


Figure13. Analytical HillShading.






NOTE : setting up a SAGA geoprocessing environment as created by rsaga.env for further arguments to rsaga.geoprocessor in this case we have rsaga.env as env = env

Original R Script

Conclusion

In conclusion, both the softwares 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

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

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

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

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

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