Description Usage Arguments Value Author(s) Examples
Masks a raster file or object on the basis of a vector file or object. Pixels not covered by the vector features are set to NoData. If the input raster is multi-band, the mask is automatically applied to all bands. An optional buffer can be applied to the input vector to allow a more "lenient" masking, or to remove also the borders of the vector.
1 2 3 4 |
in_rast |
Raster file or object inheriting class |
mask |
Vector file or object of class |
crop |
|
buffer |
|
out_nodata |
|
out_type |
Default: "rastobj" (If an invalid string is provided, defaults to |
out_basename |
|
save_multiband |
Default: FALSE |
out_dtype |
|
overwrite |
|
verbose |
|
verb_foreach |
|
object of class raster
(if out_type == rastobj
), or character
string
corresponding to the filename of the created raster (if out_type == filename
)
Lorenzo Busetto, PhD (2017) email: lbusett@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ## Not run:
library(sprawl)
library(sprawl.data)
library(raster)
in_polys <- read_vect(system.file("extdata","lc_polys.shp", package = "sprawl.data"),
stringsAsFactors = T)
in_rast <- raster::stack(system.file("extdata", "sprawl_EVItest.tif",
package = "sprawl.data"))[[1]]
in_polys <- sf::st_transform(in_polys, proj4string(in_rast))
masked <- mask_rast(in_rast, in_polys, verbose = FALSE)
plot_rast(in_rast, in_poly = in_polys)
plot_rast(masked, in_poly = in_polys)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.