TransWikia.com

Calculating Saga Wetness Index from LiDAR-derived .ASC files in RSAGA

Geographic Information Systems Asked by xtina on February 25, 2021

I am trying to run SAGA Wetness Index on a large number of .asc files that were derived from 1-m LiDAR. Due to the large size/amount of data (each .asc file is ~1000 MB and I have ~685 files), I would really like to avoid having to convert the file type to .sgrd.

I understand that ascii files can be read into RSAGA, but I’m not having much luck. I’m trying to get it running on a folder with 6 files in it and I’m trying to run slope only because seems like a simpler calculation than TWI or SAGA WI.

R version: 4.0.3
SAGA version: 2.1.0

My code was as follows:

library(RSAGA)
env <- rsaga.env("C:/Program Files (x86)/SAGA-GIS")

#I first tried this on just one file:

rsaga.slope(in.dem = "filepath", out.slope = "filepath", env = env)

#This was the error message:

library path:   C:PROGRA~2SAGA-GISmodulesta_morphometry.dll
library name:   Terrain Analysis - Morphometry
module name :   Slope, Aspect, Curvature
author      :   O.Conrad (c) 2001

Parameters

Grids: No objects
Files: filepath
Transformation: yes
Interpolation: B-Spline Interpolation

loading: filepath
Driver: filepath
Cells: x 3924, y 5372
Bands: 1
Transformation x' = 324800.000000 + x * 1.000000 + y * 0.000000
Transformation y' = 5563672.000000 + x * 0.000000 + y * -1.000000
loading band [1/1]
Slope, Aspect, Curvature: could not initialize data objects
Error: executing module [Slope, Aspect, Curvature]
Warning message:
In system(command, intern = intern, show.output.on.console = show.output.on.console,  :
  running command '"C:/Program Files (x86)/SAGA-GIS/saga_cmd.exe" -f=q ta_morphometry "Slope, Aspect, Curvature" -ELEVATION "filepath" -SLOPE "filepath" -ASPECT "filepath" -METHOD "5"' had status 1

#Also tried:

wd <- setwd("filepath")
 asc.files<-dir(wd, pattern='.asc$')
 asc.files<-substr(basename(asc.files), 1, nchar(basename(asc.files)) - 4)
 asc.files
 for (i in length(asc.files[i])) {
     rsaga.esri.wrapper(fun=rsaga.slope, in.dem=asc.files[i],
                         method="maxslope", in.esri=T, out.esri=T, clean.up=T,
                            out.slope=c(paste("SLOPE",asc.files[i],sep="")), env=env, esri.workspace=
                          "P:/AserLab/Projects/OK_Wetlands/TWI/Test", format="ascii", georef="corner", prec=3)
     }

#error was:
Error: Grid file could not be opened.
Error: input file [bc_082l013_xli1m_utm11_2018.sgrd]
Error: Elevation
Error: executing module [Slope, Aspect, Curvature]

#There was also a long warning message similar to that above.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP