I'm trying to mask a raster with a ring polygon using the function raster::mask, but only recognizes the outer edges of the polygon, can anyone help me with this? I only need the pixels within the yellow area, but it returns pixel inside the outer edge of the polygon.
library(raster)
raster<-raster("my_raster_path")
buffer<-shapefile("my_shapefile_path") #yellow buffer
output<-mask(raster, buffer)
writeRaster(output, "filename") #output grayscale raster