我正在尝试将世界地图放在我当前由关卡绘制的地块上。这个情节是这样制作的:
library(raster)
library(ncdf4)
library(maps)
library(maptools)
library(rasterVis)
library(ggplot2)
library(rgdal)
library(sp)
library(gridExtra)
MFplot4<-levelplot(MFMeaner3,margin=F, at=Fcutpoints4,cuts=11,
pretty=TRUE,par.settings=mapTheme, main="Historical five-day maximum
precipitation (mm/day) model mean")
对象“MFMeener3”具有以下属性:
class : RasterLayer
dimensions : 64, 128, 8192 (nrow, ncol, ncell)
resolution : 2.8125, 2.789327 (x, y)
extent : -181.4062, 178.5938, -89.25846, 89.25846 (xmin, xmax, ymin,
ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names : layer
values : 0.1583802, 164.2064 (min, max)
这是我在上面的图上放置世界地图叠加层的尝试:
world.outlines<-map("world", plot=FALSE)
world.outlines.sp<-map2SpatialLines(world.outlines,proj4string =
CRS("+proj=longlat"))
MFplot4 + layer(sp.lines(world.outlines.sp,col="black",lwd=0.5))
但是,这会导致以下错误:
Error: Attempted to create layer with no stat.
我还尝试使用以下方法放置一个简单的世界地图:
MFplot4 + plot(wrld_simpl)
但我收到此错误:
Error in UseMethod("as.layer") :
no applicable method for 'as.layer' applied to an object of class "NULL"
为什么会出现这些错误?
对此的任何帮助将不胜感激!