Learn R Programming

bcmaps (version 0.18.1)

raster_by_poly: Overlay a SpatialPolygonsDataFrmae or sf polygons layer on a raster layer and clip the raster to each polygon. Optionally done in parallel

Description

Overlay a SpatialPolygonsDataFrmae or sf polygons layer on a raster layer and clip the raster to each polygon. Optionally done in parallel

Usage

raster_by_poly(
  raster_layer,
  poly,
  poly_field,
  summarize = FALSE,
  parallel = FALSE,
  future_strategy = NULL,
  workers = NULL,
  ...
)

Arguments

raster_layer

the raster layer

poly

a SpatialPolygonsDataFrame layer or sf layer

poly_field

the field on which to split the SpatialPolygonsDataFrame

summarize

Should the function summarise the raster values in each polygon to a vector? Default FALSE

parallel

process in parallel? Default FALSE.

future_strategy

the strategy to use in future::plan() for parallel computation. Default NULL respects if user has already set a plan using future::plan() or an option, otherwise uses "multiprocess".

workers

number of workers if doing parallel. Default NULL uses the default of the future strategy chosen (usually future::availableCores()).

...

passed on to future::plan()

Value

a list of RasterLayers if summarize = FALSE otherwise a list of vectors.