Skip to content

paleolimbot/s2plot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)
}

About

Plot spatial objects on a sphere

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages