I'm trying to calculate morfometrics index provided by SAGA using RQGIS 3 with QGIS 3.4 version.
I`ve followed tutorial examples, but i dont have been successful. The script run, but don't produce any results. Any suggestion?
Here my script:
find_algorithms(search_term = "slope",name_only = TRUE)
get_usage("saga:slopeaspectcurvature")
params2 = get_args_man(alg = "saga:slopeaspectcurvature")
wd = "E:/artigo_declividade/mdesrtm/saga" #workdirectory
params2$ELEVATION = RQGIS3::dem
params2$METHOD = 6
params2$UNIT_SLOPE = 1
params2$UNIT_ASPECT = 1
params2$SLOPE = file.path(wd, "slope.tif")
params2$ASPECT = file.path( wd, "aspect.tif")
params2$C_GENE = file.path( wd, "generalCurvature.tif")
params2$C_PLAN = file.path( wd, "planCurvature.tif")
params2$C_PROF = file.path( wd, "profCurvature.tif")
params2$C_TANG = file.path( wd, "tangencialCurvature.tif")
params2$C_LONG = file.path( wd, "longitudinalCurvature.tif")
params2$C_CROS = file.path( wd, "crossSectionalCurvature.tif")
params2$C_MINI = file.path( wd, "minimalCurvature.tif")
params2$C_MAXI = file.path( wd, "maximalCurvature.tif")
params2$C_TOTA = file.path( wd, "totalCurvature.tif")
params2$C_ROTO = file.path( wd, "flowLineCurvature.tif")
run_qgis(alg = "saga:slopeaspectcurvature",
params = params2)
Results at Console:
$`ASPECT`
[1] "E:/artigo_declividade/mdesrtm/saga/aspect.tif"
$C_CROS
[1] "E:/artigo_declividade/mdesrtm/saga/crossSectionalCurvature.tif"
$C_GENE
[1] "E:/artigo_declividade/mdesrtm/saga/generalCurvature.tif"
$C_LONG
[1] "E:/artigo_declividade/mdesrtm/saga/longitudinalCurvature.tif"
$C_MAXI
[1] "E:/artigo_declividade/mdesrtm/saga/maximalCurvature.tif"
.
.
.
EDITED:
Im trying this. Its works until "Terrain Convexity". After that show the same behavior (morphometric functions run but with empty results).
devtools::install_github("jannes-m/RQGIS3")
require(devtools)
require(raster)
require(rgdal)
require(RQGIS3)
qgis_env <-set_env(root ='C:/Program Files/QGIS 3.4')
set_env()
open_app()
dem = RQGIS3::dem #file
wd = "E:/a" #output
morfometria = function(dem, wd){ #function that calculate many morfometric index
#aspect
params2 = get_args_man(alg = "saga:slopeaspectcurvature")
params2$ELEVATION = dem
params2$METHOD = 6
params2$UNIT_SLOPE = 1
params2$UNIT_ASPECT = 1
params2$SLOPE = file.path(wd, "slope.sdat")
params2$ASPECT = file.path( wd, "aspect.sdat")
params2$C_GENE = file.path( wd, "generalCurvature.sdat")
params2$C_PLAN = file.path( wd, "planCurvature.sdat")
params2$C_PROF = file.path( wd, "profCurvature.sdat")
params2$C_TANG = file.path( wd, "tangencialCurvature.sdat")
params2$C_LONG = file.path( wd, "longitudinalCurvature.sdat")
params2$C_CROS = file.path( wd, "crossSectionalCurvature.sdat")
params2$C_MINI = file.path( wd, "minimalCurvature.sdat")
params2$C_MAXI = file.path( wd, "maximalCurvature.sdat")
params2$C_TOTA = file.path( wd, "totalCurvature.sdat")
params2$C_ROTO = file.path( wd, "flowLineCurvature.sdat")
run_qgis(alg = "saga:slopeaspectcurvature",
params = params2)
# Valley and Ridge Detection
paramValley = get_args_man(alg = "saga:valleyandridgedetectiontophatapproach")
paramValley$DEM = dem
paramValley$VALLEY = file.path( wd, "valleyDepth.sdat")
paramValley$HILL = file.path( wd, "hillHeight.sdat")
paramValley$VALLEY_IDX = file.path( wd, "valleyIDX.sdat")
paramValley$HILL_IDX = file.path( wd, "hillIDX.sdat")
paramValley$SLOPE_IDX = file.path( wd, "slopeIDX.sdat")
run_qgis(alg = "saga:valleyandridgedetectiontophatapproach",
params = paramValley)
#Terrain Surface Convexity
paramTerrainSurfaceConvexity = get_args_man(alg = "saga:terrainsurfaceconvexity")
paramTerrainSurfaceConvexity$DEM = dem
paramTerrainSurfaceConvexity$CONVEXITY = file.path( wd, "TSConvexity.sdat")
paramTerrainSurfaceConvexity$METHOD = 1
paramTerrainSurfaceConvexity$DW_WEIGHTING = 3
run_qgis(alg = "saga:terrainsurfaceconvexity",
params = paramTerrainSurfaceConvexity)
#Terrain Surface Texture
paramTerrainSurfaceTexture = get_args_man(alg = "saga:terrainsurfacetexture")
paramTerrainSurfaceTexture$DEM = dem
paramTerrainSurfaceTexture$TEXTURE = file.path( wd, "TSTexture")
paramTerrainSurfaceTexture$METHOD = 1
paramTerrainSurfaceTexture$DW_WEIGHTING = 3
run_qgis(alg = "saga:terrainsurfacetexture",
params = paramTerrainSurfaceTexture)
#Terrain Surface Classification
paramTSC = get_args_man(alg = "saga:terrainsurfaceclassificationiwahashiandpike")
paramTSC$DEM = dem
paramTSC$LANDFORMS = file.path(wd, "Landforms1.sdat")
run_qgis(alg = "saga:terrainsurfaceclassificationiwahashiandpike",
params = paramTSC)
#TPI Based Landform Classification
paramTPILand = get_args_man(alg = "saga:tpibasedlandformclassification")
paramTPILand$DEM = dem
paramTPILand$LANDFORMS = file.path( wd, "Landforms2.sdat")
run_qgis(alg = "saga:tpibasedlandformclassification",
params = paramTPILand)
# Topographic Position Index (TPI)
paramTPI = get_args_man(alg = "saga:topographicpositionindextpi")
paramTPI$DEM = dem
paramTPI$TPI = file.path(wd, "TPI.sdat")
run_qgis(alg = "saga:topographicpositionindextpi",
params = paramTPI)
# Vector Ruggedness Index (VRI)
paramVector = get_args_man(alg = "saga:vectorruggednessmeasurevrm")
paramVector$DEM = dem
paramVector$VRM = file.path(wd, "vectorRuggednessIndex.sdat")
run_qgis(alg = "saga:vectorruggednessmeasurevrm",
params = paramVector)
# Terrain Ruggedness Index (TRI)
paramReggedness = get_args_man(alg = "saga:terrainruggednessindextri")
paramReggedness$DEM = dem
paramReggedness$TRI = file.path(wd, "terrainRuggednessIndex.sdat")
run_qgis(alg = "saga:terrainruggednessindextri",
params = paramReggedness)
# Mass Balance Index
paramMass = get_args_man(alg = "saga:massbalanceindex")
paramMass$DEM = dem
paramMass$MBI = file.path(wd, "massBalanceIndex.sdat")
run_qgis(alg = "saga:massbalanceindex",
params = paramMass)
# Downslope Distance Gradient
paramGradient = get_args_man(alg = "saga:downslopedistancegradient")
paramGradient$DEM = dem
paramGradient$GRADIENT = file.path(wd, "gradient.sdat")
paramGradient$DIFFERENCE = file.path(wd, "difference.sdat")
run_qgis(alg = "saga:downslopedistancegradient",
params = paramGradient)
# Multiresolution Index of Valley Bottom Flatness (MRVBF)
paramMultires = get_args_man(alg = "saga:multiresolutionindexofvalleybottomflatnessmrvbf")
paramMultires$DEM = dem
paramMultires$MRVBF = file.path(wd, "MRVBF.sdat")
paramMultires$MRRTF = file.path(wd, "MRRTF.sdat")
run_qgis(alg = "saga:multiresolutionindexofvalleybottomflatnessmrvbf",
params = paramMultires)
# Morphometric.Protection.Index
paramMorphometric = get_args_man(alg = "saga:morphometricprotectionindex")
paramMorphometric$DEM = dem
paramMorphometric$RADIUS = 1000
paramMorphometric$PROTECTION = file.path(wd, "morphoProtectionIndex.sdat")
run_qgis(alg = "saga:morphometricprotectionindex",
params = paramMorphometric)
#Real Surface Area
paramRealSA = get_args_man(alg = "saga:realsurfacearea")
paramRealSA$DEM = dem
paramRealSA$AREA = file.path(wd, "realSurfaceArea.sdat")
run_qgis(alg = "saga:realsurfacearea",
params = paramRealSA)
#Curvature classification
paramCurvature = get_args_man(alg = "saga:curvatureclassification")
paramCurvature$DEM = dem
paramCurvature$CLASS = file.path(wd, "curvatureClassification.sdat")
run_qgis(alg = "saga:curvatureclassification",
params = paramCurvature)
#Surface.Specific.Points
paramSSP = get_args_man(alg = "saga:surfacespecificpoints")
paramSSP$ELEVATION = dem
paramSSP$METHOD = 1
paramSSP$RESULT = file.path(wd, "surfaceSpecificPoints.sdat")
run_qgis(alg = "saga:surfacespecificpoints",
params = paramSSP)
# convergence index
paramConvergence = get_args_man(alg = "saga:convergenceindex")
paramConvergence$ELEVATION = dem
paramConvergence$NEIGHBOURS = 1
paramConvergence$RESULT = file.path(wd, "convergenceIndex.sdat")
run_qgis(alg = "saga:convergenceindex",
params = paramConvergence)
# wetness index
paramWetness = get_args_man(alg = "saga:sagawetnessindex")
paramWetness$DEM = dem
paramWetness$TWI = file.path(wd, "topographicWetIndex.sdat")
paramWetness$AREA = file.path(wd, "AREAtopographicWetIndex.sdat")
paramWetness$SLOPE = file.path(wd, "SLOPEtopographicWetIndex.sdat")
paramWetness$AREA_MOD = file.path(wd, "AREAMODtopographicWetIndex.sdat")
run_qgis(alg = "saga:sagawetnessindex",
params = paramWetness)
}
morfometria(dem = dem, wd = wd)
RQGIS3
from - it doesn't appear to be on CRAN.