我正在尝试使用r从大型netcdf文件中提取图层 我的nc文件变量是
5 variables:"
[1] " double time_bnds[bnds,time] "
[1] " double plev_bnds[bnds,plev] "
[1] " double lat_bnds[bnds,lat] "
[1] " double lon_bnds[bnds,lon] "
[1] " float hur[lon,lat,plev,time] "
[1] " standard_name: relative_humidity"
[1] " long_name: Relative Humidity"
所以我想获得特定plev和特定时间的所有lon和lat的相对湿度(hur)数据
plev<-get.var.ncdf(ncin,"plev")
time<-get.var.ncdf(ncin,"time")
plev2<-plev[2]
time2<-time[2]
hur<-get.var.ncdf(ncin,"hur",start=c(1,1,plev2,time2), count=c(1,1,2,2))
我收到此错误
Error in R_nc_get_vara_double: NetCDF: Index exceeds dimension bound
Var: hur Ndims: 4 Start: 711901,92499,0,0Count: 2,2,144,192Error in
get.var.ncdf(ncin, "hur", start = c(1, 1, plev2, time2), count = c(-1, :
C function R_nc_get_vara_double returned error
我该如何解决这个问题
编辑------
溶液
lat和lon是一个向量
hur<-get.var.ncdf(ncin,"hur", start=c(1,1,2,2),count=c(dim(lon),dim(lat),1,1))
previously i kept directly the values of plev2 but we shud mention the index which is 2
谢谢@pascal