[R] Problems trying to make a time series using NetCDF file

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Sun Mar 17 02:33:59 CET 2019


You might have better luck on the R-sig-spatial mailing list. If you had provided a reproducible example ("reprex") then I might have tried to answer the question but I don't use these tools often enough to grasp the source of your problem based only on diagnostics. And even though they might have a better chance of seeing  the issue with only diagnostics, I am sure they would appreciate a reprex too.

On March 16, 2019 10:50:46 AM PDT, rain1290--- via R-help <r-help using r-project.org> wrote:
>Hi there,
>I am using climate model data in attempt to create a time series for a
>specific location. Getting longitude and latitude is fine. However, I
>am receiving the following error when using the "ncvar_get" function in
>trying to derive the "time" dimension:
>Error in nc$dim[[idobj$list_index]] : 
>  attempt to select more than one element in get1index <real>
>What could be causing this?
>-This is what I have done so far:
>#CanESM2 plotting for specified
>yearncfname<-"MaxPrecCCCMACanESM2rcp45.nc"
>Prec<-raster(ncfname)
>print(Prec)
>Model<-nc_open(ncfname)longitude<-ncvar_get(Model, "lon") #Works fine
>latitude<-ncvar_get(Model, "lat") #Works fine
>time<-ncvar_get(Model, "time") #Error in nc$dim[[idobj$list_index]] :
>attempt to select more than one element in get1index <real>
>
>
>Here is the structure of the file after using "nc_open":
>File MaxPrecCCCMACanESM2rcp45.nc (NC_FORMAT_NETCDF4):
>
>     3 variables (excluding dimension variables):
>        double onedaymax[lon,lat,time]   (Contiguous storage)  
>            units: mm/day
>        double fivedaymax[lon,lat,time]   (Contiguous storage)  
>            units: mm/day
>        short Year[time]   (Contiguous storage)  
>
>     3 dimensions:
>        time  Size:95
>        lat  Size:64
>            units: degree North
>        lon  Size:128
>            units: degree East
>What could be causing this error? 
>Thanks in advance, and I look forward to your response!
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.



More information about the R-help mailing list