Error when trying to import NetCDF to R -


i' struggeling open netcdf file in r. when try open

library(ncdf) # read in netcdf file maize.nc<-open.ncdf("c:/users/jo/desktop/pft_harvest_maize.nc") 

i following error message:

 error in r_nc_open: netcdf: unknown file format  error in open.ncdf("c:/users/jo/desktop/pft_harvest_maize.nc") :     error in open.ncdf trying open file c:/users/jo/desktop/pft_harvest_maize.nc 

the weird thing is, netcdf file runoff-data exact same simulation exact same datatype opens without problems.

the difference in filesize runoff: 56.1 mb (58,870,472 bytes) , harvest: 149 mb (156,968,508 bytes). files not big fail when opening. has idea how can trackback error causes problem??

using rnetcdf package same problem (error: netcdf: unknown file format)

from ncdump get:

netcdf pft_harvest_maize { dimensions:         time = 199 ;         npft = 32 ;         latitude = 78 ;         longitude = 79 ; variables:         string namepft(npft) ;         int time(time) ;                 time:units = "years" ;         float latitude(latitude) ;                 latitude:units = "degrees_north" ;                 latitude:long_name = "latitude" ;             latitude:standard_name = "latitude" ;             latitude:axis = "y" ;     float longitude(longitude) ;             longitude:units = "degrees_east" ;             longitude:long_name = "longitude" ;             longitude:standard_name = "longitude" ;             longitude:axis = "x" ;     float harvest(time, npft, latitude, longitude) ;             harvest:units = "gc/m2/yr" ;             harvest:long_name = "harvested carbon" ;             harvest:missing_value = -9999.99f ;             harvest:_fillvalue = -9999.99f  } 

the file can found here: netcdf-file

the dump ncdump -k gives netcdf file format netcdf-4. able open file ncdf4 package since ncdf not seem backwards compatible version 4 files:

"however, ncdf package not provide interface netcdf version 4 files."

from ncdf4 documentation.

library(ncdf4) mycdf <- nc_open(file.choose(), verbose = true, write = false) timedata <- ncvar_get(mycdf,'time') lat <- ncvar_get(mycdf,'latitude') long <- ncvar_get(mycdf,'longitude') harvestdata <- ncvar_get(mycdf,'harvest')  str(harvestdata) 

gives

num [1:79, 1:78, 1:32, 1:199] na na na na na na na na na na ... 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -