forked from paleolimbot/s2plot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
69 lines (52 loc) · 1.5 KB
/
README.Rmd
File metadata and controls
69 lines (52 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
dpi = 300
)
```
# s2plot
<!-- badges: start -->
[](https://www.tidyverse.org/lifecycle/#experimental)
<!-- badges: end -->
The goal of s2plot is to provide a quick plot function for [s2](https://github.com/r-spatial/s2) geographies to facilitate development of that package.
## Installation
You can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("remotes")
remotes::install_github("paleolimbot/s2plot")
```
## Example
Plot s2 geographies!
```{r example}
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!
```{r spin, animation.hook='gifski', interval = 1 / 25, dpi = 96}
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)
}
```