R Levelplot sp";转换失败“;

R Levelplot sp";转换失败“;,r,sp,R,Sp,我在像这样的水平图上添加了一个图层 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.

我在像这样的水平图上添加了一个图层

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 
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)
但是,如果我添加
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>

有什么帮助吗?

会不会
sp.polygons()
产生与
sp.lines()
相同的错误?我只要求考虑到你有一个多边形数据框,这是强迫成线。我不确定这是否与您的问题有关,只是我注意到了一些问题。请尝试使用除
union
以外的其他名称;错误消息表明在某个地方使用了函数
联合
,而不是对象。