"Error: inherits(obj, "空间") is not TRUE"



我想从以下光栅对象(r1)创建等高线(50%、75%、95%),这些对象可以传输到ArcGIS。但我总是收到错误消息:"错误:继承(obj,"Spatial")不是TRUE"。

contour1 <- contour(r1, levels=c(.5, .75, .95), add=TRUE)
library(rgdal)
writeOGR(contour1, ".", paste("r1"), driver="ESRI Shapefile")
################ 

class       : RasterLayer 
dimensions  : 703, 524, 368372  (nrow, ncol, ncell)
resolution  : 10000, 10000  (x, y)
extent      : -2839438, 2400562, -3450852, 3579148  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=aeqd +ellps=WGS84 +lon_0=89.5525 +lat_0=43.234 
data source : in memory
names       : layer 
values      : 1e-07, 2.888137  (min, max)

尝试以下操作:

library(sp)
library(maptools)
l = quantile(r1[], c(.05, .5, .95))
sl = ContourLines2SLDF(contourLines(as.image.SpatialGridDataFrame(as(r1, "SpatialGridDataFrame")), levels = l))
library(rgdal)
writeOGR(sl, ".", paste("r1"), driver="ESRI Shapefile")

相关内容

最新更新