简体   繁体   中英

Clipping of raster as a shapefile in r

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM