Skip to contents

Return clipping extent with buffer radius. It assumes the input CRS is projected and linear unit is meters.

Usage

get_clip_ext(pnts, radius)

Arguments

pnts

One of sf or SpatVector object. Target points of computation.

radius

numeric(1). Buffer radius. It is assumed to be in meters

Value

A terra::ext or sfc_POLYGON object of the computation extent.

Author

Insang Song

Examples

library(sf)
library(terra)
options(sf_use_s2 = FALSE)

nc_path <- system.file("gpkg/nc.gpkg", package = "sf")
nc_sf <- sf::st_read(nc_path)
#> Reading layer `nc.gpkg' from data source 
#>   `/home/runner/work/_temp/Library/sf/gpkg/nc.gpkg' using driver `GPKG'
#> Simple feature collection with 100 features and 14 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
#> Geodetic CRS:  NAD27
nc_sf <- sf::st_transform(nc_sf, "EPSG:5070")
get_clip_ext(nc_sf, 2.5e4)
#> Geometry set for 1 feature 
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1026793 ymin: 1320525 xmax: 1860999 ymax: 1716736
#> Projected CRS: NAD83 / Conus Albers
#> POLYGON ((1026793 1320525, 1860999 1320525, 186...
nc_vect <- terra::vect(nc_sf)
get_clip_ext(nc_vect, 2.5e4)
#> SpatExtent : 1026793.1576511, 1860998.50656683, 1320525.36229524, 1716735.54884167 (xmin, xmax, ymin, ymax)