Skip to contents

Clips a vector layer using a polygon layer. It handles CRS transformations automatically if necessary, ensuring the output is in the same CRS as the input polygon.

Usage

clip_layer(vector, polygon)

Arguments

vector

An `sf` object representing the vector layer to be clipped.

polygon

An `sf` object representing the polygon layer used for clipping.

Value

An `sf` object containing the features of the input `vector` that intersect with the `polygon`. The output will be in the CRS of the `polygon`, and it will retain all attributes of the input `vector`.

See also

Other clip functions: clip_multipoligon(), clip_raster(), generate_bbox()

Examples

gpkg_path <- system.file("extdata", "clc.gpkg", package = "clc")

clc <- sf::st_read(gpkg_path, layer = "clc", quiet = TRUE)
lanjaron <- sf::st_read(gpkg_path, layer = "lanjaron", quiet = TRUE)

clc_clipped <- clip_layer(clc, lanjaron)