R - 用于JPEG Impages的裁剪

时间:2016-11-06 16:31:27

标签: r raster

我试图使用栅格图层在地图上绘制图像(标记)

# 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()的使用缺失了什么。

0 个答案:

没有答案