Generate a rectangular polygon from extent
Usage
ext2poly(extent = NULL, output_class = c("sf", "terra"), crs = "EPSG:4326")
Arguments
- extent
input extent. A numeric vector with xmin/xmax/ymin/ymax, sf::st_bbox or terra::ext outputs.
- output_class
character(1). Class of the output polygon. One of
"sf"
or"terra"
- crs
character(1). Coordinate reference system definition.
See also
Other Helper functions:
any_class_args()
,
clip_ras_ext()
,
clip_vec_ext()
,
crs_check()
,
datamod()
,
dep_check()
,
dep_switch()
,
get_clip_ext()
,
is_bbox_within_reference()
,
is_within_ref()
,
par_def_q()
,
reproject_b2r()
,
reproject_std()
,
vect_valid_repair()
Examples
library(sf)
library(terra)
numext1 <- c(-100, -70, 30, 40)
names(numext1) <- c("xmin", "xmax", "ymin", "ymax")
ext2poly(numext1, "sf")
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -100 ymin: 30 xmax: -70 ymax: 40
#> Geodetic CRS: WGS 84
#> x
#> 1 POLYGON ((-100 30, -70 30, ...
ext2poly(numext1, "terra")
#> class : SpatVector
#> geometry : polygons
#> dimensions : 1, 0 (geometries, attributes)
#> extent : -100, -70, 30, 40 (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat WGS 84 (EPSG:4326)