geom_centroids {ggautomap} | R Documentation |
Geographic centroid of locations
Description
Assigns each point a longitude and latitude corresponding to the geographic
centre of its administrative area. This means that all points in the same
area will overlap. The default position
uses position_circle_repel()
to repel the points outwards with an amount controllable with its
scale
parameter.
Usage
geom_centroids(
mapping = ggplot2::aes(),
data = NULL,
stat = "automap_coords",
position = "circle_repel_sf",
...,
fun.geometry = NULL,
feature_type = NA,
inset = NA,
map_base = "clip",
map_inset = "auto",
na.rm = TRUE,
show.legend = "point",
inherit.aes = TRUE
)
Arguments
mapping , data , stat , position , na.rm , show.legend , inherit.aes , ... |
|
fun.geometry |
A function that takes a |
feature_type |
Type of map feature. See |
inset |
Inset configuration; see |
map_base |
Controls the layer with the base map. Possible values are
|
map_inset |
Controls the layer with the inset map. Possible values are
|
Value
A ggplot layer.
Aesthetics
The location
aesthetic is required.
geom_centroids()
understands the same aesthetics as ggplot2::geom_point()
.
Examples
library(ggplot2)
cartographer::nc_type_example_2 |>
head(n = 100) |>
ggplot(aes(location = county)) +
geom_boundaries(feature_type = "sf.nc") +
geom_centroids(aes(colour = type), position = position_circle_repel_sf(scale = 6), size = 0.5) +
coord_automap(feature_type = "sf.nc")