layer_frame: Create map layer with shape framing a simple feature object

View source: R/layer_frame.R

layer_frameR Documentation

Create map layer with shape framing a simple feature object

Description

Wraps st_circle, st_square, and layer_neatline.

Usage

layer_frame(
  data,
  dist = NULL,
  diag_ratio = NULL,
  unit = "meter",
  frame = "circle",
  scale = 1,
  rotate = 0,
  inscribed = FALSE,
  color = "black",
  size = 1,
  linetype = "solid",
  fill = "white",
  neatline = TRUE,
  expand = FALSE,
  union = TRUE,
  ...
)

make_frame(
  x,
  frame = "circle",
  scale = 1,
  rotate = 0,
  inscribed = FALSE,
  dTolerance = 0
)

Arguments

data

sf or bbox class object

dist

buffer distance in units. Optional.

diag_ratio

ratio of diagonal distance of area's bounding box used as buffer distance. e.g. if the diagonal distance is 3000 meters and the "diag_ratio = 0.1" a 300 meter will be used. Ignored when dist is provided.

unit

Buffer units; defaults to meter.

frame

Type of framing shape to add, "circle" or "square" around data.

scale

numeric; scale factor, Default: 1

rotate

numeric; degrees to rotate (-360 to 360), Default: 0

inscribed

If TRUE, make circle or square inscribed within x, if FALSE, make it circumscribed.

color

Color of panel border, Default: 'black'

size

Size of panel border, Default: 1

linetype

Line type of panel border, Default: 'solid'

fill

Fill color for frame.

neatline

If TRUE, add a neatline to the returned layer.

expand

Default FALSE. If TRUE, the function adds ggplot2::scale_y_continuous() and ggplot2::scale_x_continuous() to expand the map extent to provided parameters.

union

If TRUE, union data before buffering and creating frame; defaults to TRUE.

...

Additional parameters passed to layer_location_data. May include additional fixed aesthetics (e.g. alpha) or "fn" to apply to the frame object.

x

A sf, sfc, or bbox object

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 and sf_use_s2() returns TRUE, then the value of dTolerance must be specified in meters.

See Also

Other layer: layer_icon(), layer_location_data(), layer_markers(), layer_mask(), layer_neatline(), layer_scaled()

Examples

nc <- read_sf_path(system.file("shape/nc.shp", package = "sf"))

raleigh_msa <-
  get_location(
    type = nc,
    name_col = "NAME",
    name =  c("Franklin", "Johnston", "Wake"),
    crs = 3857
    )

ggplot2::ggplot() +
  layer_frame(
    data = raleigh_msa,
    frame = "circle",
    fill = "lightyellow",
    inscribed = FALSE
  ) +
  layer_location_data(
    data = raleigh_msa,
    mapping = ggplot2::aes(fill = NAME),
    alpha = 0.5
  ) +
  ggplot2::guides(
    fill = "none"
  )

elipousson/overedge documentation built on Aug. 13, 2022, 7:41 p.m.