Support both bbox and sf objects as inputs.
Usage
st_scale_rotate(x, scale = 1, rotate = 0)
st_center(x, ext = TRUE, ...)
st_square(x, scale = 1, rotate = 0, inscribed = FALSE)
st_inscribed_square(x, scale = 1, rotate = 0)
st_circle(x, scale = 1, inscribed = FALSE, dTolerance = 0)
st_circumscribed_circle(x, scale = 1)Arguments
- x
A sf, sfc, or bbox object
- scale
numeric; scale factor, Default: 1
- rotate
numeric; degrees to rotate (-360 to 360), Default: 0
- ext
If
TRUE, st_center returns a list with the centroid as a sfc object, as an sf object (with lon and lat values), the original geometry (x), and the original crs. objects; defaults TRUE. IfFALSE, return an sf object.- ...
Additional parameters passed to
sf::st_centroid()by st_center- inscribed
If
TRUE, make circle or square inscribed within x, ifFALSE, make it circumscribed.- dTolerance
numeric; tolerance parameter, specified for all or for each feature geometry. If you run
st_simplify, the input data is specified with long-lat coordinates andsf_use_s2()returnsTRUE, then the value ofdTolerancemust be specified in meters.
Details
Scale or rotate a simple feature or bounding box object using affine transformations
Get the center point for a
sfobjectGet a circumscribed square or approximate inscribed square in a
sfobjectGet a circumscribed circle or inscribed circle in a
sfobject
st_inscribed_square wraps sf::st_inscribed_circle() but limits the circle
to 1 segment per quadrant (nQuadSegs = 1) and then rotates the resulting
geometry 45 degrees to provide a (mostly) inscribed square. A different
rotation value can be provided to change the orientation of the shape, e.g.
rotate = -45 to return a diamond shape. st_square() wraps st_bbox_ext() with
asp = 1.
Examples
nc <- read_sf_path(system.file("shape/nc.shp", package = "sf"))
nc <- st_transform_ext(nc, crs = 3857)
basemap <-
ggplot2::ggplot() +
ggplot2::geom_sf(data = nc) +
ggplot2::theme_void()
basemap +
layer_location_data(
data = st_scale_rotate(nc, scale = 0.5, rotate = 15),
fill = NA,
color = "red"
)