Adding scale bar to ggplot map
There is a package called ggsn, which allows you to customize the scale bar and north arrow.
ggplot() +
geom_path(aes(long, lat, group=group), data=worldUk, color="black", fill=NA) +
coord_equal() +
ggsn::scalebar(worldUk, dist = 100, st.size=3, height=0.01, dd2km = TRUE, model = 'WGS84')
Another option is annotation_scale
from the ggspatial package. Some more hints on this blog post.
library(ggplot2)
library(maptools)
data(wrld_simpl)
world_sf <- sf::st_as_sf(wrld_simpl)
worldUk <- subset(world_sf, NAME == 'United Kingdom')
Plot the layer and add the scale bar.
library(ggspatial)
ggplot() +
geom_sf(data = worldUk) +
annotation_scale()