mask_crop_subset: mask_crop_subset

Description Usage Arguments Details Value Examples

View source: R/mask_crop_subset.R

Description

mask and/or crop a Raster* based on a Polygon.

Usage

1
mask_crop_subset(r, p, idx = NULL, ...)

Arguments

r

Raster* object

p

SpatialPolygon* object

idx

vector of strings indicating the layer indices to subset.

...

additional arguments as in writeRaster (e.g. progress = "text")

Details

Please note that cells along the border with centroids falling outside the polygon p will not be returned. If cells along the border are needed, we suggest to identify cells covering the polygon and set all remaining pixels to NA, as described in this post: https://goo.gl/22LwJt.

Value

A Raster* object with resolution and land-sea mask matching those of r and extent matching p.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 

  # Define dummy polygon
  shape <- as(raster::extent(7, 18, 37, 40), "SpatialPolygons")
  
  # Read RISICO test data
  r_risico <- readRDS(system.file("extdata", "RISICO_raster.rds",
                                  package = "caliver"))
  
  mask_crop_subset(r = r_risico, p = shape)


## End(Not run)

caliver documentation built on Feb. 19, 2021, 5:07 p.m.