> -----Original Message----- > From: r-sig-geo-boun...@stat.math.ethz.ch > [mailto:r-sig-geo-boun...@stat.math.ethz.ch] On Behalf > Of gianni lavaredo > Sent: Tuesday, April 07, 2009 4:44 PM > To: r-sig-geo@stat.math.ethz.ch > Subject: [R-sig-Geo] problem to module MERGE GRID in RSAGA > > Dear R Users > > I have a problem to understand the loop merge in RSAGA > > I have this file (not order name) > DEM2644147 > DEM2644148 > DEM2644149 > DEM2744150 > DEM2744155 > DEM2744168 > > I did a file list in CSV: > > path<- ("C:/mydata/") > temp <- paste(path,"input.csv", sep="") > input <- read.csv(temp, header = TRUE) > attach(input) > names(input) > temp <- file > file.list <- as.list(temp) > > > # USE POWER TO DEM > power <- seq(1.0, 10.0, by=0.1) > > # power of DCM > for(i in 1:length(file.list)){ > for (method in 1:length(power)){ > rsaga.grid.calculus(in.grids = c(paste("C:/mydata/DEM", > file.list[[i]],".sgrd", sep="")), > out.grid = > c(paste("C:/mydata/Power_DEM",file.list[[i]],"_",method+9,".sgrd",sep="")), > formula = paste("a^",power[method],sep="")) > } > } > > #TRY with two DEM with power^1 > rsaga.geoprocessor(lib="grid_tools", module=3, > param=list(GRIDS="C:/mydata/Power_DEM2644147_10.sgrd;C:/mydata/Power_DEM2644148_10.sgrd", > MERGED="C:/mydata/merge_power10.sgrd",TYPE=6,INTERPOL=0,OVERLAP=0)) > > Now I am trying to merge in a LOOP every DEM to have: > all_merge_power10 > all_merge_power11 > all_merge_power12 > all_merge_power13 > etc > > > for(i in 1:length(file.list)){ > for (method in 1:length(power)){ > rsaga.geoprocessor(lib="grid_tools", module=3, > > param=list(GRIDS=c(paste("C:/mydata/Power_DEM",file.list[[i]],"method+9",".sgrd",sep="")), > MERGED="C:/mydata/all_merge_power10.sgrd", > TYPE=6, > INTERPOL=0, > OVERLAP=0)) > } > }
why do you loop? simly do: > GRIDS=paste(set.file.extension(file.list, ".sgrd"), collapse=";") There is also no need to write the working directory every time. Just set it up at the beginning: > setwd("C:/mydata/") Some similar examples here: http://spatial-analyst.net/wiki/index.php?title=Software#SAGA_GIS T. Hengl > > > > I have diffucult to load all DEM power 10, ect etc and every time I have a > Error :-(. > > Thanks a lot > > Gianni > > [[alternative HTML version deleted]] > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/r-sig-geo _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo