1

I'm trying to plot a image (a flag) on a map using raster layers and

# 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")

When I try to crop, I get an error:

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"’

But I can't figure out what I'm missing about the use of crop().

waealu
  • 331
  • 1
  • 9

0 Answers0