Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am writing a rasterbrick with multiple layers to a netcdf file using the raster package in R:

writeRaster(gridfile, "Data", "CDF", overwrite=TRUE,
     varname="Data",varunit="mm.d-1",longname="Monthly data",
     xname="lon",yname="lat", zname="time", zunit="month",bylayer=FALSE,NAflag=-9999)

Is there a way to have the data with time coordinates in the written ncdf file? E.g. in the NetCDF Viewer Panoply I can plot the data in [lon][lat] but not in [time][lat].

Also how can specify the timesteps as specific months in a year instead of the timesteps starting from 1 and increasing?

share|improve this question
    
I have found a solution using the ncdf package: stat.ethz.ch/pipermail/r-sig-geo/2013-January/017265.html However, is there a way to directly do this through the raster package? –  Dom Apr 19 '13 at 12:36
    
Can you add some data, or at least include str(gridfile) and sessionInfo() so we know your R, raster, and ncdf/ncdf4 versions? –  mdsumner Apr 22 '13 at 21:20
add comment

2 Answers

You should use the R-Package netcdf package, it has much more possibilities to taylor your resulting data fields. To hold the GIS connectvity use the Lon/Lat attribute schema beside the time attribute (Spatial temporal advises ).

If you want to create and use spatio temporal datasets like in climatology you should read the best practice article of unidata.ucar.edu. There are several tools which work with netcdf spatio temporal standard structures.

Mapping netcdf - NCL | NCO netCDF-Operator | CDO - Climate Data Operators


NCL Example

enter image description here


Bye Huck

share|improve this answer
add comment

Valid units strings for CF-compliant netcdf files look like "seconds since 1970-01-01 00:00:00" or "days since 2013-04-19 00:00:00"

I think "months since ...." isn't supported by udunits since months are not equally sized.

You might do better thinking of the z dimension as a record dimension and then add a time variable with ncdf that locates each record in time.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.