我正在添加一个图层,如此
levelplot(x)+layer(sp.lines(shape,col='black',lwd=2))
其中x
>x
dimensions : 90, 180, 16200 (nrow, ncol, ncell)
resolution : 1.999556, 1.867778 (x, y)
extent : -180, 179.92, -78.1, 90 (xmin, xmax, ymin, ymax)
coord. ref. : NA
data source : in memory
names : layer
values : -12.23738, 19.81 (min, max)
和shape
>shape
class : SpatialPolygonsDataFrame
features : 101
extent : -180, 180, -85.47029, 90 (xmin, xmax, ymin, ymax)
coord. ref. : NA
variables : 5
names : ID, NAME, Gazetteer_, NEWID, NEWNAME
min values : 1, Adriatic Sea, 1904, 17, Arctic
max values : 9, Yellow Sea, 5698, 67, South Pacific
但是,如果我添加union
而不是shape
> union
class : SpatialPolygonsDataFrame
features : 7
extent : -180, 180, -85.47029, 90 (xmin, xmax, ymin, ymax)
coord. ref. : NA
variables : 1
names : ID
min values : 1
max values : 7
我收到此错误:
In grid.Call.graphics(L_text, as.graphicsAnnot(x$label), ... :
conversion failure on 'unable to find an inherited method for function ‘sppanel’ for signature ‘"function"’' in 'mbcsToSbcs': dot substituted for <80>
这是我从union
shape
的方法
gpclibPermit()
union <- unionSpatialPolygons(shape, ID=shape@data$NEWID)
unionid <- sapply(slot(union, "polygons"), function(x) slot(x, "ID"))
uniondf <- data.frame( ID=1:length(union), row.names = unionid)
union <- SpatialPolygonsDataFrame(union, uniondf)
任何帮助?