Skip to content
Prev 17845 / 29559 Next

writeRaster - netcdf - Rotation

Hi Robert and Pascal,
?
thanks for the tips, but my problem isn't completely solved. The explicit laebling of x and y works, but doesn't change the rotation.
I followed Pascals hint:
My raster*-Object has the dimensons: "220 171 x".
When I export this raster*-Obejct as posted below as nc-file and reimport it with the ncdf-Package, the dimensions are: "171 220 x". The explicit labeling doesn't change that. The first dimension is always 171 in the nc-file, no matter if its names 'easting' or 'northing'. To me it looks like raster and ncdf interpret x and y differently?!
?
Beste regards
Philipp
?
?
Philipp,

You are right, the labels easting and northing are reversed. I will fix
that. You can set them yourself as illustrated below:

library(raster)
tmp<- raster(nr=5, nc=10,crs='+proj=utm +zone=12')
tmp[] <- 1:ncell(tmp)
writeRaster(tmp, filename='export.nc', format="CDF", overwrite=TRUE,
xname='easting', yname='northing')
raster('export.nc')

nc <- open.ncdf("export.nc")
get.var.ncdf(nc,"easting")

Robert
On Fri, Mar 22, 2013 at 7:17 AM, <amock at gmx.li> wrote: