I want use the function "filled.contour", but my data file are ncdf4 file.
how to convert ncdf4 file to data.frame in R?
Some advice?
thanks
I want use the function "filled.contour", but my data file are ncdf4 file.
how to convert ncdf4 file to data.frame in R?
Some advice?
thanks
Because a NetCDF file can contain objects of many different dimensions, it is not a straightforward conversion. If you know the names of the variable you want to get out of the file you can do it like this:
library(ncdf4)
nc<-nc_open("filename")
ncvar_get(nc,varid= "variableNameInFile" )
nc_close(nc)
If you dont know the names of the attributes in your file you can use this to obtain them:
library(ncdf4)
nc<-nc_open("filename")
var.idNames<-names(nc$var)
nc_close(nc)
Once you extract the individual variables you can just put them into a dataframe (data.frame()) if they are the same dimensions.
Hope this Helps! (and don't forget to close your file when you're done)