wmap_sf | R Documentation |
This function is intended to be used in two ways: first, to overlay a world map on an existing gg object, and second, to create a base world map using ggplot2.
wmap_sf(
sfmap = NULL,
sf_resol = 50,
pacific_centered = TRUE,
as_gg = TRUE,
lgl = NULL,
ltl = NULL,
lgb = NULL,
ltb = NULL,
...
)
sfmap |
World map data in sf format, Default: NULL |
sf_resol |
Resolution of sf world map data passed to
|
pacific_centered |
If TRUE (default), the world map is centred on the Pacific Ocean; if FALSE, the world map is centred on the prime meridian (i.e. the meridian on Greenwich). |
as_gg |
Whether or not to make a gg object, Default: TRUE |
lgl |
Longitude limits, Default: NULL |
ltl |
Latitude limits, Default: NULL |
lgb |
Longitude breaks, Default: NULL |
ltb |
Latitude breaks, Default: NULL |
... |
Arguments passed to |
If sfmap is NULL, the default map projection system is a geographic coordinate system based on the WGS84. It has not yet been checked whether there are any problems with other coordinate reference systems. See example and vignette("wmap_sf").
gg or a list (LayerInstance)
ne_countries
st_break_antimeridian
, st_shift_longitude
library(ggplot2)
library(frabento)
set.seed(180)
df <- data.frame(Long = seq(140, 240, by = 5),
Lati = runif(n = 21, min = 40, max = 65),
group = c(rep(1:5, each = 4), 6))
# plain world map as pacific centered (default)
wmap_sf()
# plain world map as Greenwich centered
wmap_sf(pacific_centered = FALSE)
# Trim worldmap and overlay data points on worldmap
wmap_sf(lgl = c(135, 245), ltl = c(35, 70)) +
geom_point(data = df, aes(x = Long, y = Lati, color = as.factor(group)))
# Trim world map and overlay worldmap on data points
ggplot() +
geom_point(data = df, aes(x = Long, y = Lati, color = as.factor(group))) +
wmap_sf(as_gg = FALSE, lgl = c(135, 245), ltl = c(35, 70))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.