Skip to content

Instantly share code, notes, and snippets.

@marcosci
Created November 2, 2022 12:29

Revisions

  1. marcosci created this gist Nov 2, 2022.
    46 changes: 46 additions & 0 deletions day02_lines.R
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    library(sf)
    library(tidyverse)

    projections <- c("+proj=laea",
    "+proj=moll",
    "+proj=adams_ws2",
    "+proj=urm5 +n=0.9",
    "+proj=wintri",
    "+proj=bonne +lat_1=10",
    "+proj=eck1",
    "+proj=fouc",
    "+proj=larr",
    "+proj=nicol",
    "+proj=murd1 +lat_1=30 +lat_2=50",
    "+proj=rpoly")


    world <- map_dfr(projections, function(projection){
    world <- sf::st_graticule(lon=seq(-180,180, 15),
    lat = seq(-90,90, 7.5),
    ndiscr = 5000,
    margin = 0.00000000001) %>%
    st_transform(projection)
    world$crs <- str_split(projection, " ")[[1]][1]
    world
    })

    ggplot() +
    geom_sf(data = world, size = 0.3, color = "#424242", alpha = 0.6) +
    facet_wrap(vars(crs)) +
    labs(title = "Coordinate Reference Systems - Graticules",
    caption = "Data: naturalearth | Visualisation: Marco Sciaini") +
    theme(panel.grid.major = element_blank(),
    text=element_text(family="iA Writer Duospace"),
    strip.background = element_rect(fill= alpha('#cd5c5c', 0.5), colour = NA),
    strip.text=element_text(size = 9,
    face = "bold"),
    panel.background = element_rect(fill= alpha('#cd5c5c', 0.1), colour = NA),
    plot.title = element_text(size = 26,
    face = "bold",
    colour = '#212832',
    margin = margin(.3,0,1,0, "cm")),
    plot.caption = element_text(size = 7,
    colour = '#212832',
    margin = margin(.3,0,.3,0, "cm"))
    )