[R-sig-Geo] RSAGA .asc morphology loop question
Alexander Brenning
brenning at uwaterloo.ca
Sun Mar 1 16:43:29 CET 2009
Hi Tim,
the rsaga.esri.wrapper currently expects the in.* and out.* arguments
(with the ASCII/float ESRI grids) to have NO file extension - the file
extension to be used for all ESRI grids can be given by the
esri.extension argument; it currently defaults to ".asc" when
format="ascii" and to ".flt" when format="binary". (Sorry that the help
file is not explicit enough regarding the file extensions; will add this
to the next update.)
Two more remarks on your code:
> read.ascii.grid(i)
This simply reads the grid but does nothing else - redundant.
> prec=1
Slope is calculated in radians (see ?rsaga.slope). So with a 0.1 radian
increment (the smallest increment that can be represented with prec=1
digits) you get 0.1 * 180 / pi = 5.7 degree increments on the degree
scale - you probably want to haver a finer discretization. I would
recommend prec=3 in the case of slope (and probably prec=6 or 7 for
curvature attributes).
I hope this helps.
Cheers
Alex
Tim Sippel wrote:
> I'm using RSAGA (version 0.9-4) to calculate rate of change (slope) on a
> series of .asc files. I'm getting en error message saying it can't open the
> grid. My code follows:
>
> library(RSAGA)
> # data directory containing my .asc files to calculate slope on
> wd.in<-"C:\\my.data.dir"
> setwd(wd.in)
> env<-rsaga.env(path="C:\\programs\\saga_vc", cmd="saga_cmd.exe")
> asc.list<-dir(wd.in, pattern='.asc$')
> for (i in asc.list) {
> read.ascii.grid(i)
> rsaga.esri.wrapper(fun=rsaga.slope, in.dem=i, method="maxslope",
> in.esri=T, out.esri=T, clean.up=T,
> out.slope=c(paste("SLOPE",as.character(i),sep="")), env=env,
> esri.workspace=wd.in, format="ascii", georef="corner", prec=1)
> }
>
> Here are some of the data files in my directory from my asc.list object
> above:
>
> asc.list
> [1] "tmp1_220E-15N2005-03-02.asc" "tmp10_220E-15N2005-05-13.asc"
> "tmp100_220E-15N2007-05-13.asc" "tmp101_220E-15N2007-05-21.asc"
> [5] "tmp102_220E-15N2007-05-29.asc" "tmp103_220E-15N2007-06-06.asc"
> "tmp104_220E-15N2007-06-14.asc" "tmp105_220E-15N2007-06-22.asc"
>
> The error I'm getting is below:
>
> SAGA CMD 2.0.3
> library path: C:\programs\saga_vc/modules
> library name: ta_morphometry
> module name : Local Morphometry
> author : (c) 2001 by O.Conrad
> Load grid: tmp1_220E-15N2005-03-02.asc...
> failed
> error: Grid file could not be opened.
> error: input file [tmp1_220E-15N2005-03-02.asc]
> error: executing module [Local Morphometry]
>
> Not sure what I've done wrong in calling in the grid files and would
> appreciate advice.
>
> Best regards,
>
> Tim Sippel
> University of Auckland
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
--
Alexander Brenning
brenning at uwaterloo.ca - T +1-519-888-4567 ext 35783
Department of Geography and Environmental Management
University of Waterloo
200 University Ave. W - Waterloo, ON - Canada N2L 3G1
http://www.fes.uwaterloo.ca/geography/faculty/brenning/
More information about the R-sig-Geo
mailing list