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

Thomas Adams Thomas.Adams at noaa.gov
Wed Apr 21 22:00:08 CEST 2010


Robert,

My apologies, your suggestion

data<-readRAST6(unlist(map_list))

did work, only I had another error in my scripting that made it appear 
that your suggestion was not working. Thank you so much for your help. 
I'm still very much a novice with most of R!

Regards,
Tom


Edzer Pebesma wrote:
> 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
>>
>>     
>
>   


-- 
Thomas E Adams
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177

EMAIL:	thomas.adams at noaa.gov

VOICE:	937-383-0528
FAX:	937-383-0033



More information about the R-sig-Geo mailing list