plotExtent: Create spatial polygon same size as a plot

View source: R/plotExtent.r

plotExtentR Documentation

Create spatial polygon same size as a plot

Description

This function creates a "rectangular" SpatVector object with the same dimensions as a plot window. It is especially useful for cropping subsequent rasters or vector objects to the plot window. A plot must be made before calling this function.

Usage

plotExtent(x = NULL)

Arguments

x

Either NULL (default), an object of class crs, a coordinate reference string (PROJ6 WKT string), or an object with a coordinate reference system. If any of these is provided, the SpatVector object will have this CRS.

Value

SpatVector

See Also

extentToVect

Examples


if (FALSE) {

library(sf)

data(mad0)
plot(st_geometry(mad0))
outline <- plotExtent(mad0)
plot(outline, col='cornflowerblue', lty='dotted')
plot(st_geometry(mad0), add=TRUE)

}


enmSdmX documentation built on April 3, 2025, 7:50 p.m.