This function creates a bounding box polygon from it's corner coordinates, setting the coordinate reference system from the supplied EPSG value.
create_bounding_box(xmin, ymin, xmax, ymax, epsg_number)
xmin | The left corners easting coordinate as an integer or double. |
---|---|
ymin | The lower corners northing coordinate as an integer or double. |
xmax | The right corners easting coordinate as an integer or double. |
ymax | The upper corners northing coordinate as an integer or double. |
epsg_number | EPSG number as an integer. |
The bounding box polygon returned as a sf spatial object.
The function was created following the approach taken in the stack overflow polygons from coordinates.
suppressPackageStartupMessages({ library(store) }) create_bounding_box(xmin = -10.81, ymin = 49.85, xmax = 2.07, ymax = 60.96, epsg = 4326)#> Simple feature collection with 1 feature and 1 field #> Geometry type: POLYGON #> Dimension: XY #> Bounding box: xmin: -10.81 ymin: 49.85 xmax: 2.07 ymax: 60.96 #> Geodetic CRS: WGS 84 #> id geom #> 1 1 POLYGON ((-10.81 49.85, -10...