Skip to contents

This function creates a rectangle of specified width and height, centered on a given point.

Usage

st_create_rectangle(center, xsize, ysize, crs = 2193)

Arguments

center

A numeric vector of length 2 specifying the x and y coordinates of the center of the rectangle (e.g., c(x, y)).

xsize

Numeric, the total width of the rectangle (in the same units as the coordinate reference system, typically meters).

ysize

Numeric, the total height of the rectangle (in the same units as the coordinate reference system, typically meters).

crs

Numeric, the coordinate reference system (CRS) of the output geometry. Default is EPSG:2193 (NZTM2000).

Value

An sf object representing the rectangle polygon.

Examples

if (FALSE) { # \dontrun{
# Example usage: Create a rectangle with width 1000 meters and height 500 meters centered at (1577107, 5173732) in NZTM2000
rectangle_sf <- st_create_rectangle(center = c(1577107, 5173732), xsize = 1000, ysize = 500)

# Plot the rectangle
plot(rectangle_sf)
} # }