The world as a globe (orthographic projection) centred on lon/lat – the
honest answer to "the whole world on a rectangle exaggerates the poles". Takes
the same fill / style options as world_map(). The default "sf" backend
gives the cleanest limb; the "polygon" backend draws the globe with
ggplot2::coord_map() and needs only mapproj (no sf).
Usage
globe_map(
data,
fill,
lon = 0,
lat = 20,
backend = c("sf", "polygon"),
style = c("quantile", "continuous", "binned", "equal", "jenks", "fisher", "headtails",
"sd", "fixed", "categorical"),
palette = NULL,
n_bins = 5,
breaks = NULL,
midpoint = NULL,
borders = TRUE,
title = NULL,
legend = NULL,
na_label = "No data",
footnote = "auto",
small_states = c("auto", "none", "dots"),
small_area_km2 = 1000,
interactive = FALSE
)Arguments
- data
A map-ready frame: an
sfframe forbackend = "sf", or a country-level frame withiso3c(or a polygon frame) forbackend = "polygon".- fill
The fill column (unquoted).
- lon, lat
The longitude / latitude the globe is centred on (the face pointing at the viewer).
- backend
"sf"(default, viaggplot2::coord_sf()) or"polygon"(viaggplot2::coord_map(), nosfrequired).- style, palette, n_bins, breaks, midpoint, borders, title, legend, na_label
As in
world_map().- footnote, small_states, small_area_km2
As in
world_map().- interactive
If
TRUE, return a MapLibre WebGL globe you can spin and zoom instead of a static image. Needsmapgland ansfframe;lonandlatbecome the initial camera position and the drawing arguments above do not apply.
Examples
# \donttest{
# No sf required -- the polygon backend needs only mapproj:
if (requireNamespace("mapproj", quietly = TRUE)) {
globe_map(countryatlas::world_snapshot$countries, continent,
backend = "polygon", style = "categorical")
}
# }
if (FALSE) { # \dontrun{
# The sf backend gives the cleanest limb (needs a World Bank fetch):
world_data(2020, geometry = "sf") |>
globe_map(gdp_per_capita, lon = 10, lat = 30)
} # }
