Skip to content
Prev 18884 / 29559 Next

Clipping raster by polygon

Hi Joseph,

I wrote a function that you can use to clip every raster object with any
polygon within the raster package.

######################################
clip<-function(raster,shape) {
          a1_crop<-crop(raster,shape)
          step1<-rasterize(shape,a1_crop)
          a1_crop*step1}
######################################

Much success.

Carsten
On 07/17/2013 07:02 PM, Robert J. Hijmans wrote: