[R-sig-Geo] Trying to read a list of maps using readRAST6

Edzer Pebesma edzer.pebesma at uni-muenster.de
Wed Apr 21 20:48:58 CEST 2010


Thomas, perhaps:

data <- readRAST6(map_list[[1]])

as map_list is a list, and readRAST6 seems to want a character vector,
which is in the first list element of map_list.

Thomas Adams wrote:
> All:
> 
> With sp & spgrass6 I have no problem reading a list of maps with
> readRAST6 when I do the following:
> 
> data<-readRAST6(c("map1","map2","map3",…))
> 
> however, I need to do this dynamically within a script, for example:
> 
>> inputfile<-Sys.getenv("R_INPUT_FILE")
>> map_list<-scan(inputfile,list(""))
> 
> Read 21 records
> 
>> map_list
> 
> [[1]]
> [1] "sref_em.t09z.pgrb212.ctl" "sref_em.t09z.pgrb212.n1"
> [3] "sref_em.t09z.pgrb212.n2" "sref_em.t09z.pgrb212.p1"
> [5] "sref_em.t09z.pgrb212.p2" "sref_eta.t09z.pgrb212.ctl1"
> [7] "sref_eta.t09z.pgrb212.ctl2" "sref_eta.t09z.pgrb212.n1"
> [9] "sref_eta.t09z.pgrb212.n2" "sref_eta.t09z.pgrb212.p1"
> [11] "sref_eta.t09z.pgrb212.p2" "sref_nmm.t09z.pgrb212.ctl"
> [13] "sref_nmm.t09z.pgrb212.n1" "sref_nmm.t09z.pgrb212.n2"
> [15] "sref_nmm.t09z.pgrb212.p1" "sref_nmm.t09z.pgrb212.p2"
> [17] "sref_rsm.t09z.pgrb212.ctl1" "sref_rsm.t09z.pgrb212.n1"
> [19] "sref_rsm.t09z.pgrb212.n2" "sref_rsm.t09z.pgrb212.p1"
> [21] "sref_rsm.t09z.pgrb212.p2"
> 
> 
> data<-readRAST6(map_list)
> spplot(data,…)
> 
> What happens is that "map_list" is treated literally, not as:
> data<-readRAST6(c("map1","map2","map3",…)) which works. I have tried a
> number of things, such as:
> 
> data<-readRAST6(as.list(map_list))
> data<-readRAST6(c(map_list))
> data<-readRAST6(as.vector(map_list))
> data<-readRAST6(eval(map_list))
> 
> How do I do this?
> 
> Regards,
> Tom
> 

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list