我试图使用栅格图层在地图上绘制图像(标记)
# Load packages
library(maptools)
library(raster)
library(jpeg)
# Read in a jpeg and convert to raster
usa.flag <- as.raster(readJPEG(".../usa.jpg"))
# Get spacial image of map
data("wrld_simpl")
usa.map <- subset(wrld_simpl, NAME == "United States")
当我尝试裁剪时,我收到错误:
usa.sub <- crop(usa.flag, extent(usa.map))
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘crop’ for signature ‘"raster"’
但我无法弄清楚我对crop()
的使用缺失了什么。