Hi,
I have a rasterBrick object that I have created through a series of
manipulations and written to disk using writeRaster(x,format="CDF"). In
another, independent script, I then need to read that netcdf file back in.
The following commands work:
b <- brick("Bluefin_OISST_clim.nc")
plot(b)
but these don't:
crop(b,extent(320,340,55,60))
Error in ncvar_get_inner(ncid2use, varid2use, nc$var[[li]]$missval,
addOffset, :
Error: variable has 2 dims, but start has 3 entries. They must match!
readAll(b)
Error in ncvar_get_inner(ncid2use, varid2use, nc$var[[li]]$missval,
addOffset, :
Error: variable has 2 dims, but start has 3 entries. They must match!
On Wed, 25 May 2016 at 19:59 Mark R Payne <markpayneatwork at gmail.com> wrote:
Hi,
I have a rasterBrick object that I have created through a series of
manipulations and written to disk using writeRaster(x,format="CDF"). In
another, independent script, I then need to read that netcdf file back in.
The following commands work:
b <- brick("Bluefin_OISST_clim.nc")
plot(b)
but these don't:
crop(b,extent(320,340,55,60))
Error in ncvar_get_inner(ncid2use, varid2use, nc$var[[li]]$missval,
addOffset, :
Error: variable has 2 dims, but start has 3 entries. They must match!
readAll(b)
Error in ncvar_get_inner(ncid2use, varid2use, nc$var[[li]]$missval,
addOffset, :
Error: variable has 2 dims, but start has 3 entries. They must match!
I don't know the proper fix, but it works if you use a RasterLayer rather
than a 1-layer RasterBrick:
crop(b[[1]],extent(320,340,55,60))
It's straightforwardly a bug IMO, due to the logic of a 1-layer degenerate
dimension - and one for the the raster maintainer. If you can look at the
source of raster:::.readRowsBrickNetCDF you'll probably find it if for a
suggested fix or patch.
Cheers, Mike.
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia
[[alternative HTML version deleted]]