Skip to contents

This function rapidly masks a RasterLayer object to a sf object.

Usage

mask_raster_to_polygon(ras, mask, inverse = FALSE, updatevalue = NA)

Arguments

ras

A RasterLayer object.

mask

A RasterLayer or sf object.

inverse

A logical flag. If TRUE, the mask is inverted (default: FALSE).

updatevalue

The value to update the RasterLayer object 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)
#>