In the R Raster package, when I load a netCDF file into a raster and attempt to mask or crop the raster with a shapefile, I am getting the error:
"*Error in `colnames<-`(`*tmp*`, value = names(object)) :
attempt to set 'colnames' on an object with less than two dimensions*"
Here is example code
library(ncdf4)
library(raster)
nc <- brick("in.netcdf.nc", varname = "diff", values=TRUE )
crs(nc) <- "+proj=utm +zone=17 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"
everShp <- shapefile("EVERareas")
nc.sub <- mask(nc, everShp)
Plotting shows both nc and everShp are 2D and spatially overlap. Thanks for any suggestions with this error.
if I replace
with
the mask and crop commands work as expected.