knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%",
  dpi = 300
)

s2plot

Lifecycle: experimental

The goal of s2plot is to provide a quick plot function for s2 geographies to facilitate development of that package.

Installation

You can install the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("paleolimbot/s2plot")

Example

Plot s2 geographies!

library(s2plot)
library(s2)

s2plot(s2::s2_data_countries(), col = "grey90")
s2plot(s2::s2_data_cities("London"), pch = 16, add = T)

Make a spinning globe!

countries <- s2_data_countries()
ocean <- s2_difference(
  # make a polygon of the whole earth!
  as_s2_geography(TRUE),
  s2_union_agg(countries)
)

lat <- 0
for (lon in seq(0, -360, length.out = 101)[-1]) {
  s2plot(
    countries, 
    col = "white", border = "black", 
    projection = s2plot_projection_orthographic(sprintf("POINT (%s %s)", lon, lat)),
    xlim = c(-1, 1),
    ylim = c(-1, 1)
  )

  s2plot(ocean, col = "#0073B8", add = T)
}


paleolimbot/s2plot documentation built on July 10, 2020, 12:35 a.m.