Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rm(list=ls())
- library(ncdf4)
- #day="20150501"
- hour=c("00","01","02","03","04","05","06","07","08","09","10",11:23)
- class(hour)
- #----------------Solution 1----------------
- nc<-list()
- for(i in c(0:23)){
- precip.file<-paste("C:\\Users\\TOM\\Desktop\\R(資料庫)\\20150501\\gsmap_mvk.20150501.",
- paste(hour[i],paste("00.v6.4133.0",".nc")),sep="")
- #precip<-"C:\\Users\\TOM\\Desktop\\R(資料庫)\\20150501\\gsmap_mvk.20150501."00"00.v6.4133.0.nc"
- # i<-i+1
- nc[i]<-nc_open(precip.file) #List Contain all nc file
- }
- precip.file
- View(matrix(precip.file))
- #----------------Solution 2----------------
- read_nc_file<-function(hr){
- filepath<-paste("C:\\Users\\TOM\\Desktop\\R(資料庫)\\20150501\\gsmap_mvk.20150501.",
- paste(hr,paste("00.v6.4133.0",".nc")),sep="")
- return(nc_open(filepath))
- }
- nc<-lapply(hour,read_nc_file) #List Contain all nc file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement