Description Usage Arguments Details Value Examples
View source: R/mask_crop_subset.R
mask and/or crop a Raster* based on a Polygon.
1 | mask_crop_subset(r, p, idx = NULL, ...)
|
r |
Raster* object |
p |
SpatialPolygon* object |
idx |
vector of strings indicating the layer indices to subset. |
... |
additional arguments as in writeRaster
(e.g. |
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.
A Raster* object with resolution and land-sea mask matching those of
r
and extent matching p
.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.