Mask a RasterLayer object to a sf object
Source: R/mask_raster_to_polygon.R
mask_raster_to_polygon.RdThis function rapidly masks a RasterLayer object to
a sf object.
Arguments
- ras
A
RasterLayerobject.- mask
A
RasterLayerorsfobject.- inverse
A
logicalflag. IfTRUE, the mask is inverted (default:FALSE).- updatevalue
The value to update the
RasterLayerobject with (default:NA).
Value
A masked RasterLayer object.
Examples
naples_population |> mask_raster_to_polygon(naples_shape)
#> class : RasterLayer
#> dimensions : 146, 261, 38106 (nrow, ncol, ncell)
#> resolution : 0.0008333333, 0.0008333333 (x, y)
#> extent : 14.13542, 14.35292, 40.79292, 40.91458 (xmin, xmax, ymin, ymax)
#> crs : +proj=longlat +datum=WGS84 +no_defs
#> source : memory
#> names : pop_napoli
#> values : 0, 1399.186 (min, max)
#>