Dear R Users and Thanks Tomislav

My problem is in this RSAGA module to load all file "_10" (_11, _12, _13)
and merge together


The real data-base has not an order name and I have more over 100 files
(this is an example to understand)
DEM2644147_10.sgrd
DEM2644147_11.sgrd
DEM2644147_12.sgrd
DEM2644147_13.sgrd
DEM2644147_14.sgrd
DEM2644147_15.sgrd
DEM2644147_16.sgrd
DEM2644147_17.sgrd
DEM2644147_18.sgrd
DEM2644147_19.sgrd
DEM2644147_20.sgrd
DEM2644148_10.sgrd
DEM2644148_11.sgrd
DEM2644148_12.sgrd
DEM2644148_13.sgrd
DEM2644148_14.sgrd
DEM2644148_15.sgrd
DEM2644148_16.sgrd
DEM2644148_17.sgrd
DEM2644148_18.sgrd
DEM2644148_19.sgrd
DEM2644148_20.sgrd
DEM2644149_10.sgrd
DEM2644149_12.sgrd
DEM2644149_13.sgrd
DEM2644149_14.sgrd
DEM2644149_15.sgrd
DEM2644149_16.sgrd
DEM2644149_17.sgrd
DEM2644149_18.sgrd
DEM2644149_19.sgrd
DEM2644149_20.sgrd

to Merge: DEM2644147_10+DEM2644148_10+DEM2644149_10 = Merge_DEM_10
to Merge: DEM2644147_11+DEM2644148_11+DEM2644149_11 = Merge_DEM_11
to Merge: DEM2644147_12+DEM2644148_12+DEM2644149_12 = Merge_DEM_12
to Merge: DEM2644147_13+DEM2644148_13+DEM2644149_13 = Merge_DEM_13
to Merge: DEM2644147_14+DEM2644148_14+DEM2644149_10 = Merge_DEM_14
to Merge: DEM2644147_15+DEM2644148_15+DEM2644149_15 = Merge_DEM_15
------------------------------------------
to Merge: DEM2644147_20+DEM2644148_20+DEM2644149_20 = Merge_DEM_20


I am using RSAGA (lib="grid_tools", module=3) with a loop.
without loop (ex: DEM2644147_10+DEM2644148_10+DEM2644149_10)

rsaga.geoprocessor(lib="grid_tools", module=3,
param=list("C:/mydata/DEM2644147_10;DEM2644148_10;DEM2644149_10",
      MERGED=Merge_DEM_10,TYPE=6,
      INTERPOL=0,
      OVERLAP=0))
with loop

power <- seq(10.0, 20.0, by=1)
for(i in 1:length(file.list)){# main loop
 for (method in 1:length(power)){
 rsaga.geoprocessor(lib="grid_tools", module=3,
   param=list(GRIDS=paste("C:/mydata/DEM",file.list[[i]],"_10",".sgrd",sep=""),
   MERGED=paste("C:/mydata/Plots_Merge","_10",".sgrd",sep=""),
   TYPE=6,
   INTERPOL=0,
   OVERLAP=0))
 }
 }

ERROR = Merging: There is nothing to merge, because less than 2 grids have
been selected.

I have a promblem to load all "_10.sgrd" files because when i use ";" to
separate the file to merge there is always an error message.

Thanks for help
Gianni


2009/4/7 Tomislav Hengl <T.Hengl@uva.nl>

>
> > -----Original Message-----
> > From: r-sig-geo-bounces@stat.math.ethz.ch [mailto:
> r-sig-geo-bounces@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
>

	[[alternative HTML version deleted]]

