0

I want to clip a raster using shapefile in r as a shape of shapefile. I used crop function but it clipping as extents not as a shape. Please help me

Satya Chandra
  • 728
  • 2
  • 12
  • 26

1 Answers1

4

Crop, as stated in the manual pages, crops to the extent of the object, for your purposes you may use raster::mask(), with the same syntaxis of crop mask function "Creates a new Raster* object that has the same values as x, except for the cells that are NA (or other maskvalue) in a ’mask’." You may pass inverse=T so you get those values out of the spatialPolygon.

Elio Diaz
  • 566
  • 2
  • 19