Maestría en Ecohidrología
Universidad de Cuenca
http://www.ucuenca.edu.ec/maestria-ecohidrologia/

Daniela Ballari (PhD)
dballari@uazuay.edu.ec
Universidad del Azuay
Publicaciones - https://scholar.google.com/citations?user=1VcAm9AAAAAJ



Objetivo de la práctica: Objetivo de la práctica. Explorar el uso de la libreria RSAGA para analisis geomorfométrico. Este material fue creado utilizando: - https://cran.r-project.org/web/packages/RSAGA/vignettes/RSAGA-landslides.pdf
- https://cran.r-project.org/web/packages/RSAGA/vignettes/RSAGA.html
- Vern Cimmery (2010) User Guide for SAGA (version 2.0.5) Volume 2. Capitulos 4 y 5
- http://www.headwateranalytics.com/blog/delineate-a-watershed-with-saga-gis-and-r4
- http://www.headwateranalytics.com/blog/delineating-a-watershed-with-saga-gis-and-r-part-2

Lecturas

Engelhardt, Blake M., Peter J. Weisberg, and Jeanne C. Chambers. “Influences of watershed geomorphology on extent and composition of riparian vegetation.” Journal of Vegetation Science 23.1 (2012): 127-139.http://www.fs.fed.us/rm/pubs_other/rmrs_2011_engelhardt_b001.pdf
Olaya Victor (Ed.) (2011) Sistemas de Información Geográfica, Capítulo 15 “Geomorfometría y análisis del terreno”.(https://github.com/volaya/libro-sig/releases/download/v2.0/Libro_SIG.pdf)

Presentación introductoria
Práctica en Qgis y Saga
Práctica en Arcgis

0.0.1 Temario

A- Cargar librerias y datos
B- Explorar RSAGA
C- Pendiente
D-Delimitación de cuencas hidrográficas

1 A- Cargar librerias y datos

Datos para esta práctica Aqui

library(raster)
## Loading required package: sp
## Warning: package 'sp' was built under R version 3.4.4
library(RSAGA)
## Warning: package 'RSAGA' was built under R version 3.4.4
## Loading required package: gstat
## Warning: package 'gstat' was built under R version 3.4.4
## Loading required package: shapefiles
## Warning: package 'shapefiles' was built under R version 3.4.4
## Loading required package: foreign
## 
## Attaching package: 'shapefiles'
## The following objects are masked from 'package:foreign':
## 
##     read.dbf, write.dbf
## Loading required package: plyr
library(sf)
## Warning: package 'sf' was built under R version 3.4.4
## Linking to GEOS 3.6.1, GDAL 2.2.3, proj.4 4.9.3
library(latticeExtra)
## Loading required package: lattice
## Loading required package: RColorBrewer
dem <- raster("s03_w079_3arc_v2.tif")
projection(dem)
## [1] "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
dem_utm <- projectRaster(dem,crs=("+init=epsg:32717"))

zona_estudio<-st_read("C:/R_ecohidrologia/seriestemporalesraster/prov_zona_estudio.shp")
## Reading layer `prov_zona_estudio' from data source `C:\R_ecohidrologia\seriestemporalesraster\prov_zona_estudio.shp' using driver `ESRI Shapefile'
## Simple feature collection with 7 features and 11 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 557012.9 ymin: 9445216 xmax: 979220 ymax: 9841834
## epsg (SRID):    32717
## proj4string:    +proj=utm +zone=17 +south +datum=WGS84 +units=m +no_defs
spplot(dem_utm, col.regions=terrain.colors(255))

spplot(as(zona_estudio[1], "Spatial"), fill="transparent", col="black", under = FALSE)+as.layer(spplot(dem_utm, col.regions=terrain.colors(255)))

writeRaster(dem_utm, filename="dem_utm.sgrd", format="SAGA", overwrite=TRUE)
## class       : RasterLayer 
## dimensions  : 1213, 1214, 1472582  (nrow, ncol, ncell)
## resolution  : 92.7, 92.7  (x, y)
## extent      : 721782.3, 834320.1, 9667472, 9779917  (xmin, xmax, ymin, ymax)
## coord. ref. : NA 
## data source : C:\R_ecohidrologia\geomorfometría\dem_utm.sgrd 
## names       : s03_w079_3arc_v2 
## values      : 311.812, 5284.223  (min, max)

2 B- Explorar RSAGA

Running the geoprocessing functions requires that SAGA is installed and can be found by RSAGA. The rsaga.env() function creates a list with system-dependent information on SAGA path, module path and data directory. The function should be called with the path to the SAGA executable:

rsaga.env(path="C:/Program Files (x86)/QGIS 3.2/apps/saga-ltr")
## Verify specified path to SAGA command line program...
## Found SAGA command line program. Search for not specified SAGA modules path... 
## Done
## $workspace
## [1] "."
## 
## $cmd
## [1] "saga_cmd.exe"
## 
## $path
## [1] "C:/Program Files (x86)/QGIS 3.2/apps/saga-ltr"
## 
## $modules
## [1] "C:/Program Files (x86)/QGIS 3.2/apps/saga-ltr/modules"
## 
## $version
## [1] "2.3.2"
## 
## $cores
## [1] NA
## 
## $parallel
## [1] FALSE
## 
## $lib.prefix
## [1] ""
env <- rsaga.env(path="C:/Program Files (x86)/QGIS 3.2/apps/saga-ltr")
## Verify specified path to SAGA command line program...
## Found SAGA command line program. Search for not specified SAGA modules path... 
## Done
rsaga.get.version(env = env)
## [1] "2.3.2"
# rsaga.get.modules() 

#funciones en R
rsaga.hillshade(in.dem="dem_utm.sgrd",out.grid="hillshade",env = env )
## 
## 
## SAGA Version: 2.3.2 (32 bit)
## 
## library path: C:\PROGRA~2\QGIS3~1.2\apps\saga-ltr\modules\
## library name: ta_lighting
## library     : Lighting, Visibility
## tool        : Analytical Hillshading
## author      : O.Conrad, V.Wichmann (c) 2003-2013
## processors  : 4 [4]
## 
## Load grid: dem_utm.sgrd...
## 
## 
## Parameters
## 
## 
## Grid system: 92.7; 1214x 1213y; 721828.605299x 9667518.100606y
## Elevation: dem_utm
## Analytical Hillshading: Analytical Hillshading
## Shading Method: Standard
## Azimuth [Degree]: 315.000000
## Height [Degree]: 45.000000
## Exaggeration: 4.000000
## 
## Save grid: hillshade.sgrd...
hillshade <- raster("hillshade.sdat")
spplot(hillshade,col.regions=rev(gray(seq(0,1,.01))))

#funciones en saga
rsaga.get.usage("ta_lighting",0,env = env)
## library path: C:\PROGRA~2\QGIS3~1.2\apps\saga-ltr\modules\
## library name: ta_lighting
## library     : Lighting, Visibility
## Usage: saga_cmd ta_lighting 0 [-ELEVATION <str>] [-SHADE <str>] [-METHOD <str>] [-AZIMUTH <double>] [-DECLINATION <double>] [-EXAGGERATION <double>] [-SHADOW <str>] [-NDIRS <num>] [-RADIUS <double>]
##   -ELEVATION:<str>       Elevation
##  Grid (input)
##   -SHADE:<str>           Analytical Hillshading
##  Grid (output)
##   -METHOD:<str>          Shading Method
##  Choice
##  Available Choices:
##  [0] Standard
##  [1] Standard (max. 90Degree)
##  [2] Combined Shading
##  [3] Ray Tracing
##  [4] Ambient Occlusion
##  Default: 0
##   -AZIMUTH:<double>      Azimuth [Degree]
##  Floating point
##  Default: 315.000000
##   -DECLINATION:<double>  Height [Degree]
##  Floating point
##  Default: 45.000000
##   -EXAGGERATION:<double> Exaggeration
##  Floating point
##  Default: 4.000000
##   -SHADOW:<str>          Shadow
##  Choice
##  Available Choices:
##  [0] slim
##  [1] fat
##  Default: 1
##   -NDIRS:<num>           Number of Directions
##  Integer
##  Minimum: 2
##  Default: 8
##   -RADIUS:<double>       Search Radius
##  Floating point
##  Minimum: 0.001000
rsaga.geoprocessor("ta_lighting",0,list(ELEVATION="dem_utm.sgrd",SHADE="hillshade2",EXAGGERATION=2),env = env)
## 
## 
## SAGA Version: 2.3.2 (32 bit)
## 
## library path: C:\PROGRA~2\QGIS3~1.2\apps\saga-ltr\modules\
## library name: ta_lighting
## library     : Lighting, Visibility
## tool        : Analytical Hillshading
## author      : O.Conrad, V.Wichmann (c) 2003-2013
## processors  : 4 [4]
## 
## Load grid: dem_utm.sgrd...
## 
## 
## Parameters
## 
## 
## Grid system: 92.7; 1214x 1213y; 721828.605299x 9667518.100606y
## Elevation: dem_utm
## Analytical Hillshading: Analytical Hillshading
## Shading Method: Standard
## Azimuth [Degree]: 315.000000
## Height [Degree]: 45.000000
## Exaggeration: 2.000000
## 
## Save grid: hillshade2...
hillshade2 <- raster("hillshade2.sdat")
spplot(hillshade2,col.regions=rev(gray(seq(0,1,.01))))

3 C-Pendiente

#Preprocessing/Sink Removal
rsaga.sink.removal(in.dem="dem_utm.sgrd",,out.dem="demsink",method=1,env = env)
## 
## 
## SAGA Version: 2.3.2 (32 bit)
## 
## library path: C:\PROGRA~2\QGIS3~1.2\apps\saga-ltr\modules\
## library name: ta_preprocessor
## library     : Preprocessing
## tool        : Sink Removal
## author      : O. Conrad (c) 2001
## processors  : 4 [4]
## 
## Load grid: dem_utm.sgrd...
## 
## 
## Parameters
## 
## 
## Grid system: 92.7; 1214x 1213y; 721828.605299x 9667518.100606y
## DEM: dem_utm
## Sink Route: <not set>
## Preprocessed DEM: Preprocessed DEM
## Method: Fill Sinks
## Threshold: no
## Threshold Height: 100.000000
## 
## Create index: dem_utm [no sinks]
## Find Pits
## Find Outlets
## Routing
## Finalize
## number of processed sinks: 8778
## Initializing direction matrix...
## I'm fillin'...
## Save grid: demsink.sgrd...
demsink <- raster("demsink.sdat")
spplot(demsink,col.regions=terrain.colors(255))

#Calculo de pendiente con función rsaga.slope. rsaga.slope(in.dem, out.slope, method = "maxslope",  env = rsaga.env(), ...)
rsaga.slope(in.dem="demsink.sgrd",out.slope="slope",method="maxslope",env = env)
## 
## 
## SAGA Version: 2.3.2 (32 bit)
## 
## library path: C:\PROGRA~2\QGIS3~1.2\apps\saga-ltr\modules\
## library name: ta_morphometry
## library     : Morphometry
## tool        : Slope, Aspect, Curvature
## author      : O.Conrad (c) 2001
## processors  : 4 [4]
## 
## Load grid: demsink.sgrd...
## 
## 
## Parameters
## 
## 
## Grid system: 92.7; 1214x 1213y; 721828.605299x 9667518.100606y
## Elevation: demsink
## Slope: Slope
## Aspect: Aspect
## General Curvature: <not set>
## Profile Curvature: <not set>
## Plan Curvature: <not set>
## Flow Line Curvature: <not set>
## Method: maximum slope (Travis et al. 1975)
## Slope Units: radians
## Aspect Units: radians
## 
## Save grid: slope.sgrd...
## Save grid: C:\Users\Usuario\AppData\Local\Temp\Rtmp6RYjkY\file45c42e0c3e03...
slope <- raster("slope.sdat")
# cslope está en radianes, debe convertirse a grados
rad_a_grado = round(180/pi, 4)
formula = paste(rad_a_grado, "*a", sep = "")
rsaga.grid.calculus("slope", "slopegrados", formula,env = env)
## 
## 
## SAGA Version: 2.3.2 (32 bit)
## 
## library path: C:\PROGRA~2\QGIS3~1.2\apps\saga-ltr\modules\
## library name: grid_calculus
## library     : Calculus
## tool        : Grid Calculator
## author      : A.Ringeler (c) 2003
## processors  : 4 [4]
## 
## Load grid: slope.sgrd...
## 
## 
## Parameters
## 
## 
## Grid system: 92.7; 1214x 1213y; 721828.605299x 9667518.100606y
## Grids: 1 object (slope)
## Grids from different Systems: No objects
## Result: Result
## Formula: 57.2958*a
## Name: Calculation
## Take Formula: no
## Use NoData: no
## Data Type: 4 byte floating point number
## 
## Save grid: slopegrados.sgrd...
slope <- raster("slopegrados.sdat")
spplot(slope, zlim=c(0,40))

rsaga.get.modules("ta_morphometry",env = env)
## $ta_morphometry
##    code                                                    name
## 1     0                                Slope, Aspect, Curvature
## 2     1                                       Convergence Index
## 3     2                       Convergence Index (Search Radius)
## 4     3                                 Surface Specific Points
## 5     4                                Curvature Classification
## 6     5                                              Hypsometry
## 7     6                                       Real Surface Area
## 8     7                           Morphometric Protection Index
## 9     8 Multiresolution Index of Valley Bottom Flatness (MRVBF)
## 10    9                             Downslope Distance Gradient
## 11   10                                      Mass Balance Index
## 12   11                              Effective Air Flow Heights
## 13   12                             Diurnal Anisotropic Heating
## 14   13                                Land Surface Temperature
## 15   14                    Relative Heights and Slope Positions
## 16   15                  Wind Effect (Windward / Leeward Index)
## 17   16                          Terrain Ruggedness Index (TRI)
## 18   17                         Vector Ruggedness Measure (VRM)
## 19   18                        Topographic Position Index (TPI)
## 20   19                       TPI Based Landform Classification
## 21   20                                 Terrain Surface Texture
## 22   21                               Terrain Surface Convexity
## 23   22      Terrain Surface Classification (Iwahashi and Pike)
## 24   23                                   Morphometric Features
## 25   24           Valley and Ridge Detection (Top Hat Approach)
## 26   25                   Fuzzy Landform Element Classification
## 27   26                         Upslope and Downslope Curvature
## 28   27                                   Wind Exposition Index
##    interactive
## 1        FALSE
## 2        FALSE
## 3        FALSE
## 4        FALSE
## 5        FALSE
## 6        FALSE
## 7        FALSE
## 8        FALSE
## 9        FALSE
## 10       FALSE
## 11       FALSE
## 12       FALSE
## 13       FALSE
## 14       FALSE
## 15       FALSE
## 16       FALSE
## 17       FALSE
## 18       FALSE
## 19       FALSE
## 20       FALSE
## 21       FALSE
## 22       FALSE
## 23       FALSE
## 24       FALSE
## 25       FALSE
## 26       FALSE
## 27       FALSE
## 28       FALSE
rsaga.get.usage("ta_morphometry",0,env = env)
## library path: C:\PROGRA~2\QGIS3~1.2\apps\saga-ltr\modules\
## library name: ta_morphometry
## library     : Morphometry
## Usage: saga_cmd ta_morphometry 0 [-ELEVATION <str>] [-SLOPE <str>] [-ASPECT <str>] [-C_GENE <str>] [-C_PROF <str>] [-C_PLAN <str>] [-C_TANG <str>] [-C_LONG <str>] [-C_CROS <str>] [-C_MINI <str>] [-C_MAXI <str>] [-C_TOTA <str>] [-C_ROTO <str>] [-METHOD <str>] [-UNIT_SLOPE <str>] [-UNIT_ASPECT <str>]
##   -ELEVATION:<str>   Elevation
##  Grid (input)
##   -SLOPE:<str>       Slope
##  Grid (output)
##   -ASPECT:<str>      Aspect
##  Grid (output)
##   -C_GENE:<str>      General Curvature
##  Grid (optional output)
##   -C_PROF:<str>      Profile Curvature
##  Grid (optional output)
##   -C_PLAN:<str>      Plan Curvature
##  Grid (optional output)
##   -C_TANG:<str>      Tangential Curvature
##  Grid (optional output)
##   -C_LONG:<str>      Longitudinal Curvature
##  Grid (optional output)
##   -C_CROS:<str>      Cross-Sectional Curvature
##  Grid (optional output)
##   -C_MINI:<str>      Minimal Curvature
##  Grid (optional output)
##   -C_MAXI:<str>      Maximal Curvature
##  Grid (optional output)
##   -C_TOTA:<str>      Total Curvature
##  Grid (optional output)
##   -C_ROTO:<str>      Flow Line Curvature
##  Grid (optional output)
##   -METHOD:<str>      Method
##  Choice
##  Available Choices:
##  [0] maximum slope (Travis et al. 1975)
##  [1] maximum triangle slope (Tarboton 1997)
##  [2] least squares fitted plane (Horn 1981, Costa-Cabral & Burgess 1996)
##  [3] 6 parameter 2nd order polynom (Evans 1979)
##  [4] 6 parameter 2nd order polynom (Heerdegen & Beran 1982)
##  [5] 6 parameter 2nd order polynom (Bauer, Rohdenburg, Bork 1985)
##  [6] 9 parameter 2nd order polynom (Zevenbergen & Thorne 1987)
##  [7] 10 parameter 3rd order polynom (Haralick 1983)
##  Default: 6
##   -UNIT_SLOPE:<str>  Slope Units
##  Choice
##  Available Choices:
##  [0] radians
##  [1] degree
##  [2] percent
##  Default: 0
##   -UNIT_ASPECT:<str> Aspect Units
##  Choice
##  Available Choices:
##  [0] radians
##  [1] degree
rsaga.geoprocessor("ta_morphometry",0,list(ELEVATION="demsink.sgrd",SLOPE="slope2",METHOD =0),env = env)
## 
## 
## SAGA Version: 2.3.2 (32 bit)
## 
## library path: C:\PROGRA~2\QGIS3~1.2\apps\saga-ltr\modules\
## library name: ta_morphometry
## library     : Morphometry
## tool        : Slope, Aspect, Curvature
## author      : O.Conrad (c) 2001
## processors  : 4 [4]
## 
## Load grid: demsink.sgrd...
## 
## 
## Parameters
## 
## 
## Grid system: 92.7; 1214x 1213y; 721828.605299x 9667518.100606y
## Elevation: demsink
## Slope: Slope
## Aspect: Aspect
## General Curvature: <not set>
## Profile Curvature: <not set>
## Plan Curvature: <not set>
## Flow Line Curvature: <not set>
## Method: maximum slope (Travis et al. 1975)
## Slope Units: radians
## Aspect Units: radians
## 
## Save grid: slope2...
slope2 <- raster("slope2.sdat")
spplot(slope2, zlim=c(0,40))

4 D-Delimitación de cuencas hidrográficas

4.0.0.1 1- Area de Captación - Catchment Area.

Para una celda, el area de captación es el area de todas las celdas aguas arriba que proveerán con flujo de agua a dicha celda. Algoritmos de ruteo de flujo: D8, Rho8,FD8, Dinf, KRA, DEMON

rsaga.get.modules("ta_hydrology",env = env)
## $ta_hydrology
##    code                                   name interactive
## 1     0           Flow Accumulation (Top-Down)       FALSE
## 2     1          Flow Accumulation (Recursive)       FALSE
## 3     2       Flow Accumulation (Flow Tracing)       FALSE
## 4     4                           Upslope Area       FALSE
## 5     6                       Flow Path Length       FALSE
## 6     7                           Slope Length       FALSE
## 7    10                           Cell Balance       FALSE
## 8    13                     Edge Contamination       FALSE
## 9    15                     SAGA Wetness Index       FALSE
## 10   16                             Lake Flood       FALSE
## 11   18   Flow Accumulation (Mass-Flux Method)       FALSE
## 12   19 Flow Width and Specific Catchment Area       FALSE
## 13   20        Topographic Wetness Index (TWI)       FALSE
## 14   21                     Stream Power Index       FALSE
## 15   22                              LS Factor       FALSE
## 16   23               Melton Ruggedness Number       FALSE
## 17   24                                TCI Low       FALSE
## 18   25                 LS-Factor, Field Based       FALSE
## 19   26        Slope Limited Flow Accumulation       FALSE
## 20   27               Maximum Flow Path Length       FALSE
rsaga.get.usage("ta_hydrology",0,env = env) ; rsaga.get.usage("ta_hydrology","Catchment Area (Parallel)",env = env)
## library path: C:\PROGRA~2\QGIS3~1.2\apps\saga-ltr\modules\
## library name: ta_hydrology
## library     : Hydrology
## Usage: saga_cmd ta_hydrology 0 [-ELEVATION <str>] [-SINKROUTE <str>] [-WEIGHTS <str>] [-FLOW <str>] [-VAL_INPUT <str>] [-VAL_MEAN <str>] [-ACCU_MATERIAL <str>] [-ACCU_TARGET <str>] [-ACCU_TOTAL <str>] [-ACCU_LEFT <str>] [-ACCU_RIGHT <str>] [-STEP <num>] [-FLOW_UNIT <str>] [-FLOW_LENGTH <str>] [-LINEAR_VAL <str>] [-LINEAR_DIR <str>] [-METHOD <str>] [-LINEAR_DO <str>] [-LINEAR_MIN <num>] [-CONVERGENCE <double>] [-NO_NEGATIVES <str>] [-WEIGHT_LOSS <str>]
##   -ELEVATION:<str>       Elevation
##  Grid (input)
##   -SINKROUTE:<str>       Sink Routes
##  Grid (optional input)
##   -WEIGHTS:<str>         Weights
##  Grid (optional input)
##   -FLOW:<str>            Flow Accumulation
##  Grid (output)
##   -VAL_INPUT:<str>       Input for Mean over Catchment
##  Grid (optional input)
##   -VAL_MEAN:<str>        Mean over Catchment
##  Grid (output)
##   -ACCU_MATERIAL:<str>   Material for Accumulation
##  Grid (optional input)
##   -ACCU_TARGET:<str>     Accumulation Target
##  Grid (input)
##   -ACCU_TOTAL:<str>      Accumulated Material
##  Grid (optional output)
##   -ACCU_LEFT:<str>       Accumulated Material (Left Side)
##  Grid (optional output)
##   -ACCU_RIGHT:<str>      Accumulated Material (Right Side)
##  Grid (optional output)
##   -STEP:<num>            Step
##  Integer
##  Minimum: 1
##  Default: 1
##   -FLOW_UNIT:<str>       Flow Accumulation Unit
##  Choice
##  Available Choices:
##  [0] number of cells
##  [1] cell area
##  Default: 1
##   -FLOW_LENGTH:<str>     Flow Path Length
##  Grid (optional output)
##   -LINEAR_VAL:<str>      Linear Flow Threshold Grid
##  Grid (optional input)
##   -LINEAR_DIR:<str>      Channel Direction
##  Grid (optional input)
##   -METHOD:<str>          Method
##  Choice
##  Available Choices:
##  [0] Deterministic 8
##  [1] Rho 8
##  [2] Braunschweiger Reliefmodell
##  [3] Deterministic Infinity
##  [4] Multiple Flow Direction
##  [5] Multiple Triangular Flow Directon
##  [6] Multiple Maximum Downslope Gradient Based Flow Directon
##  Default: 4
##   -LINEAR_DO:<str>       Thresholded Linear Flow
##  Boolean
##  Default: 0
##   -LINEAR_MIN:<num>      Linear Flow Threshold
##  Integer
##  Default: 500
##   -CONVERGENCE:<double>  Convergence
##  Floating point
##  Minimum: 0.000000
##  Default: 1.100000
##   -NO_NEGATIVES:<str>    Prevent Negative Flow Accumulation
##  Boolean
##  Default: 1
##   -WEIGHT_LOSS:<str>     Loss through Negative Weights
## Warning in rsaga.get.usage("ta_hydrology", "Catchment Area (Parallel)", : usage description not available for module Catchment Area (Parallel)
## in library ta_hydrology (interactive module?)
rsaga.topdown.processing(in.dem = "demsink.sgrd", out.carea = "carea",  method="mfd",env = env)#Multiple Flow Direction
## 
## 
## SAGA Version: 2.3.2 (32 bit)
## 
## library path: C:\PROGRA~2\QGIS3~1.2\apps\saga-ltr\modules\
## library name: ta_hydrology
## library     : Hydrology
## tool        : Flow Accumulation (Top-Down)
## author      : O.Conrad (c) 2001-2016, T.Grabs portions (c) 2010
## processors  : 4 [4]
## 
## Load grid: demsink.sgrd...
## 
## 
## Parameters
## 
## 
## Grid system: 92.7; 1214x 1213y; 721828.605299x 9667518.100606y
## Elevation: demsink
## Sink Routes: <not set>
## Weights: <not set>
## Flow Accumulation: Flow Accumulation
## Input for Mean over Catchment: <not set>
## Material for Accumulation: <not set>
## Step: 1
## Flow Accumulation Unit: cell area
## Flow Path Length: <not set>
## Channel Direction: <not set>
## Method: Multiple Flow Direction
## Thresholded Linear Flow: no
## Convergence: 1.100000
## 
## Create index: demsink
## Save grid: carea.sgrd...
carea <- raster("carea.sdat")
spplot(carea) #0 sin contribución y 1 contribución total

4.0.0.2 2- Redes de drenaje - Channel Networks.

Identifca cuales son cauces y cuales no. Cauces: flujo encauzado, no cause: flujo en laderas. Area de Captación es comúnmente usado como initation grid

rsaga.get.modules("ta_channels",env = env)
## $ta_channels
##   code                                      name interactive
## 1    0                           Channel Network       FALSE
## 2    1                          Watershed Basins       FALSE
## 3    2               Watershed Basins (Extended)       FALSE
## 4    3      Vertical Distance to Channel Network       FALSE
## 5    4 Overland Flow Distance to Channel Network       FALSE
## 6    5       Channel Network and Drainage Basins       FALSE
## 7    6                            Strahler Order       FALSE
## 8    7                              Valley Depth       FALSE
rsaga.get.usage("ta_channels","Channel Network",env = env)
## library path: C:\PROGRA~2\QGIS3~1.2\apps\saga-ltr\modules\
## library name: ta_channels
## library     : Channels
## Usage: saga_cmd ta_channels 0 [-ELEVATION <str>] [-SINKROUTE <str>] [-CHNLNTWRK <str>] [-CHNLROUTE <str>] [-SHAPES <str>] [-INIT_GRID <str>] [-INIT_METHOD <str>] [-INIT_VALUE <double>] [-DIV_GRID <str>] [-DIV_CELLS <num>] [-TRACE_WEIGHT <str>] [-MINLEN <num>]
##   -ELEVATION:<str>       Elevation
##  Grid (input)
##   -SINKROUTE:<str>       Flow Direction
##  Grid (optional input)
##   -CHNLNTWRK:<str>       Channel Network
##  Grid (output)
##   -CHNLROUTE:<str>       Channel Direction
##  Grid (output)
##   -SHAPES:<str>          Channel Network
##  Shapes (output)
##   -INIT_GRID:<str>       Initiation Grid
##  Grid (input)
##   -INIT_METHOD:<str>     Initiation Type
##  Choice
##  Available Choices:
##  [0] Less than
##  [1] Equals
##  [2] Greater than
##  Default: 2
##   -INIT_VALUE:<double>   Initiation Threshold
##  Floating point
##  Default: 0.000000
##   -DIV_GRID:<str>        Divergence
##  Grid (optional input)
##   -DIV_CELLS:<num>       Tracing: Max. Divergence
##  Integer
##  Minimum: 1
##  Default: 5
##   -TRACE_WEIGHT:<str>    Tracing: Weight
##  Grid (optional input)
##   -MINLEN:<num>          Min. Segment Length
##  Integer
rsaga.geoprocessor("ta_channels",0,list(ELEVATION="demsink.sgrd",CHNLNTWRK="channel_net.sdat",CHNLROUTE="route.sdat",SHAPES='channel_net_shp.shp',INIT_GRID="carea.sgrd",INIT_METHOD= 2,INIT_VALUE=5000000),env = env)
## 
## 
## SAGA Version: 2.3.2 (32 bit)
## 
## library path: C:\PROGRA~2\QGIS3~1.2\apps\saga-ltr\modules\
## library name: ta_channels
## library     : Channels
## tool        : Channel Network
## author      : (c) 2001 by O.Conrad
## processors  : 4 [4]
## 
## Load grid: demsink.sgrd...
## Load grid: carea.sgrd...
## 
## 
## Parameters
## 
## 
## Grid system: 92.7; 1214x 1213y; 721828.605299x 9667518.100606y
## Elevation: demsink
## Flow Direction: <not set>
## Channel Network: Channel Network
## Channel Direction: Channel Direction
## Channel Network: Channel Network
## Initiation Grid: carea
## Initiation Type: Greater than
## Initiation Threshold: 5000000.000000
## Divergence: <not set>
## Tracing: Max. Divergence: 5
## Tracing: Weight: <not set>
## Min. Segment Length: 10
## 
## Create index: demsink
## Channel Network: Pass 1
## Channel Network: Pass 2
## Channel Network: Pass 3
## Channel Network: Pass 4
## Channel Network: Pass 5
## Channel Network: Pass 6
## Save grid: channel_net.sdat...
## Save grid: route.sdat...
## Save shapes: channel_net_shp.shp...
channel <- st_read("channel_net_shp.shp")
## Reading layer `channel_net_shp' from data source `C:\R_ecohidrologia\geomorfometría\channel_net_shp.shp' using driver `ESRI Shapefile'
## Simple feature collection with 1011 features and 3 fields
## geometry type:  LINESTRING
## dimension:      XY
## bbox:           xmin: 722292.1 ymin: 9667889 xmax: 834273.7 ymax: 9779871
## epsg (SRID):    NA
## proj4string:    NA
spplot(as(channel, "Spatial"), "Order")

4.0.0.3 3- Delimitación de cuencas -Watershed Basins

rsaga.get.usage("ta_channels","Watershed Basins",env = env)
## library path: C:\PROGRA~2\QGIS3~1.2\apps\saga-ltr\modules\
## library name: ta_channels
## library     : Channels
## Usage: saga_cmd ta_channels 1 [-ELEVATION <str>] [-CHANNELS <str>] [-SINKROUTE <str>] [-BASINS <str>] [-MINSIZE <num>]
##   -ELEVATION:<str>   Elevation
##  Grid (input)
##   -CHANNELS:<str>    Channel Network
##  Grid (input)
##   -SINKROUTE:<str>   Sink Route
##  Grid (optional input)
##   -BASINS:<str>      Watershed Basins
##  Grid (output)
##   -MINSIZE:<num>     Min. Size
##  Integer
rsaga.geoprocessor("ta_channels",1,list(ELEVATION="demsink.sgrd", CHANNELS="channel_net.sgrd", BASINS="basins.sgrd",MINSIZE=100),env = env)
## 
## 
## SAGA Version: 2.3.2 (32 bit)
## 
## library path: C:\PROGRA~2\QGIS3~1.2\apps\saga-ltr\modules\
## library name: ta_channels
## library     : Channels
## tool        : Watershed Basins
## author      : (c) 2001 by O.Conrad
## processors  : 4 [4]
## 
## Load grid: demsink.sgrd...
## Load grid: channel_net.sgrd...
## 
## 
## Parameters
## 
## 
## Grid system: 92.7; 1214x 1213y; 721828.605299x 9667518.100606y
## Elevation: demsink
## Channel Network: channel_net
## Sink Route: <not set>
## Watershed Basins: Watershed Basins
## Min. Size: 100
## 
## Create index: demsink
## Save grid: basins.sgrd...
basin <- raster("basins.sdat")
spplot(basin)

4.0.0.4 4- Upslope Area

rsaga.get.usage('ta_hydrology', 4,env = env)
## library path: C:\PROGRA~2\QGIS3~1.2\apps\saga-ltr\modules\
## library name: ta_hydrology
## library     : Hydrology
## Usage: saga_cmd ta_hydrology 4 [-TARGET <str>] [-TARGET_PT_X <double>] [-TARGET_PT_Y <double>] [-ELEVATION <str>] [-SINKROUTE <str>] [-AREA <str>] [-METHOD <str>] [-CONVERGE <double>]
##   -TARGET:<str>          Target Area
##  Grid (optional input)
##   -TARGET_PT_X:<double>  Target X coordinate
##  Floating point
##  Default: 0.000000
##   -TARGET_PT_Y:<double>  Target Y coordinate
##  Floating point
##  Default: 0.000000
##   -ELEVATION:<str>       Elevation
##  Grid (input)
##   -SINKROUTE:<str>       Sink Routes
##  Grid (optional input)
##   -AREA:<str>            Upslope Area
##  Grid (output)
##   -METHOD:<str>          Method
##  Choice
##  Available Choices:
##  [0] Deterministic 8
##  [1] Deterministic Infinity
##  [2] Multiple Flow Direction
##  Default: 2
##   -CONVERGE:<double>     Convergence
##  Floating point
##  Minimum: 0.001000
rsaga.geoprocessor(lib = 'ta_hydrology', 4,
                   param = list(TARGET_PT_X =808160.095,
                                TARGET_PT_Y =9701160.897,
                                ELEVATION = 'demsink.sgrd',
                                AREA = 'upslope.sgrd',
                                METHOD = 2),env = env)
## 
## 
## SAGA Version: 2.3.2 (32 bit)
## 
## library path: C:\PROGRA~2\QGIS3~1.2\apps\saga-ltr\modules\
## library name: ta_hydrology
## library     : Hydrology
## tool        : Upslope Area
## author      : (c) 2001 by O.Conrad
## processors  : 4 [4]
## 
## Load grid: demsink.sgrd...
## 
## 
## Parameters
## 
## 
## Grid system: 92.7; 1214x 1213y; 721828.605299x 9667518.100606y
## Target Area: <not set>
## Target X coordinate: 808160.095000
## Target Y coordinate: 9701160.897000
## Elevation: demsink
## Sink Routes: <not set>
## Upslope Area: Upslope Area
## Method: Multiple Flow Direction
## Convergence: 1.100000
## 
## Create index: demsink
## Save grid: upslope.sgrd...
upslope <- raster("upslope.sdat")
spplot(upslope)

rsaga.geoprocessor(lib = 'shapes_grid', 6,
                   param = list(GRID = 'upslope.sgrd',
                                POLYGONS = 'boundary.shp',
                                CLASS_ALL = 0,
                                CLASS_ID = 100,
                                SPLIT = 0),env = env)
## 
## 
## SAGA Version: 2.3.2 (32 bit)
## 
## library path: C:\PROGRA~2\QGIS3~1.2\apps\saga-ltr\modules\
## library name: shapes_grid
## library     : Grid Tools
## tool        : Vectorising Grid Classes
## author      : O.Conrad (c) 2008
## processors  : 4 [4]
## 
## Load grid: upslope.sgrd...
## 
## 
## Parameters
## 
## 
## Grid system: 92.7; 1214x 1213y; 721828.605299x 9667518.100606y
## Grid: upslope
## Polygons: Polygons
## Class Selection: one single class specified by class identifier
## Class Identifier: 100.000000
## Vectorised class as...: one single (multi-)polygon object
## Keep Vertices on Straight Lines: no
## 
## class identification
## edge detection
## edge collection
## Save shapes: boundary.shp...
basin <- st_read("boundary.shp")
## Reading layer `boundary' from data source `C:\R_ecohidrologia\geomorfometría\boundary.shp' using driver `ESRI Shapefile'
## Simple feature collection with 1 feature and 3 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 768595.8 ymin: 9683231 xmax: 833671.2 ymax: 9778156
## epsg (SRID):    NA
## proj4string:    NA
# plot it onto the DEM
plot(dem_utm)
plot(basin, add = T) 
## Warning in plot.sf(basin, add = T): ignoring all but the first attribute

Has llegado al final del material!