0

在 中R Raster package,当我将netCDF文件加载到 araster并尝试使用 amaskcrop光栅时shapefile,我收到错误:

"*Error in `colnames<-`(`*tmp*`, value = names(object)) : 
  attempt to set 'colnames' on an object with less than two dimensions*"

这是示例代码

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)

绘图显示nceverShp是 2D 和空间重叠。感谢您对此错误的任何建议。

4

1 回答 1

0

如果我更换

nc <- brick("in.netcdf.nc", varname = "diff", values=TRUE )

nc <- raster("in.netcdf.nc", varname = "diff", values=TRUE )

mask 和crop 命令按预期工作。

于 2017-09-22T17:29:10.013 回答