Skip to content
Prev 15228 / 29559 Next

Crop a raster using a shapefile

? Dear all,

? When cropping a raster using a shapefile, through 'crop' function from "raster" package, only the extent is taken into account:
class ? ? ? : Extent?
xmin ? ? ? ?: -104.4326?
xmax ? ? ? ?: -29.99736?
ymin ? ? ? ?: -40.00064?
ymax ? ? ? ?: 10?
class ? ? ? : Extent?
xmin ? ? ? ?: -73.83943?
xmax ? ? ? ?: -34.8581?
ymin ? ? ? ?: -33.77086?
ymax ? ? ? ?: 5.38289?
class ? ? ? : Extent?
xmin ? ? ? ?: -73.83772?
xmax ? ? ? ?: -34.85554?
ymin ? ? ? ?: -33.76852?
ymax ? ? ? ?: 5.38428?

? However, the cropped raster is rectangular. Is there any way to keep also the "shape" of a shapefile (and not only its extent) when performing this kind of crop operation?

? Thanks in advance,
? Thiago.