Closed sghignone closed 1 year ago
Use the st_point_on_surface()
function in sf.
library(rnaturalearth)
library(sf)
library(purrr)
library(dplyr)
library(ggplot2)
countries <- ne_countries(returnclass = "sf")
countries_center <- st_point_on_surface(countries)
ggplot() +
geom_sf(data = countries) +
geom_sf(data = countries_center,aes(size = pop_est), color = "steelblue")
Closing this since it is not related to rnaturalearth
but rather on sf
and general geo-computational manipulations.
In a ggplot plot based on whole world map, I'd like to place a geom_point (with size proportional to a variable) at a coordinate representing the 'center' of a selected list of countries. Is there a way to get the country middle point easily? Thanks