library(maps) # R Built-in library
iso3166|> gt()Maps
MADS6
Wednesday, 1 April 2026

sfmaps and ggplot2 for simple mapssf for spatial mapsrnaturalearth for sf compatible data sourcesggplotggplotgeom_polygon() give us countriesgeom_map()Caution
map() != mapping()
Great map, but input data is limited. And geom_map() is barely explained.
ggplot() +
geom_map(data = gworld,
map = gworld,
aes(map_id = region,
fill = region),
color = "black") +
geom_point(data = msa_2230,
aes(long, lat)) +
expand_limits(x = gworld$long, y = gworld$lat) +
coord_cartesian(xlim = c(5.5, 6.75),
ylim = c(48.5, 51)) +
scale_fill_discrete_qualitative(palette = "Dark 2") +
guides(fill = "none")Claus O. Wilke on projections.

Shapes are preserved, areas are severely distorted.

Areas are preserved, shapes are somewhat distorted

Note
Alaska, Hawaii, and the lower 48 are far apart; difficult to show on one map

A fair, area-preserving projection

sfArtwork by Allison Horst
The variable gdp_md is not a median GDP!
commune <- c(
Redange = "#00A4E1",
Grevenmacher = "#00A4E1",
Luxembourg = "#777",
Vianden = "#00A4E1",
Mersch = "#DC021B",
"Esch-sur-Alzette" = "#00A4E1",
Wiltz = "#DC021B",
Clervaux = "#FFF",
Diekirch = "#777",
Remich = "#FFF",
Capellen = "#FFF",
Echternach = "#FFF"
)
lux_shp |>
group_by(CANTON) |>
mutate(n = row_number(),
canton_label = if_else(n ==1, CANTON, ""),
# centroid of each elements (county level)
lon = st_coordinates(st_centroid(geometry))[,1],
lat = st_coordinates(st_centroid(geometry))[,2],
# median lon/lat of county centroids. It's a hack.
med_lon = median(lon),
med_lat = median(lat)) |>
ungroup() |>
ggplot() +
geom_sf(aes(fill = CANTON) ,
alpha = 0.7,
show.legend = FALSE, linewidth = 0.1) +
theme_bw() + scale_fill_manual(values = commune) +
geom_text(aes(x = med_lon, y = med_lat, label = canton_label), size = 4) +
# geom_sf_text does not take x, y
labs(title = "The cantons of Luxembourg",
x = NULL,
y = NULL) CRS4181: Luxembourg 1930
world |>
filter(continent != "Antarctica") |>
ggplot() +
geom_sf() +
geom_sf(mapping = aes(fill = continent)) +
scale_fill_viridis_d(name = "Continent",
na.value = "grey50") +
# Converting our position
geom_sf(data =
st_as_sf(msa_2230,
coords = c("long", "lat"),
crs = 4181), color = "red") +
# rotating globe
coord_sf(crs = 3572) #<<sfNatural Earth project in R