Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/JoGall/terminator
R port of the Leaflet.Terminator.js plugin to show day / night regions on a map
https://github.com/JoGall/terminator
Last synced: 3 months ago
JSON representation
R port of the Leaflet.Terminator.js plugin to show day / night regions on a map
- Host: GitHub
- URL: https://github.com/JoGall/terminator
- Owner: JoGall
- Created: 2018-01-25T12:35:07.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-25T13:02:39.000Z (almost 7 years ago)
- Last Synced: 2024-05-21T02:53:28.013Z (6 months ago)
- Language: R
- Homepage:
- Size: 4.88 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# terminator
This is a simple R port of the [Leaflet](https://rstudio.github.io/leaflet/morefeatures.html) plugin [Leaflet.Terminator.js](https://github.com/joergdietrich/Leaflet.Terminator/blob/master/L.Terminator.js) intended to indicate day and night regions on a map.
Although this function worked for `leaflet` maps, I made this function in order to visualise terminators on `ggplot` maps, such as animations like this:
![terminator-animation](https://user-images.githubusercontent.com/17113779/35389041-096c2786-01ce-11e8-98b6-cfa915f8e989.gif)
Produced like so:
```{r}
library(dplyr)
library(ggplot2)
library(ggthemes)
library(gganimate)
library(animation)terminatorLatLon <- lapply(seq(0, 23, 1), function(x) {
t0 <- as.POSIXct(Sys.Date()) + (60*60*x)
terminator(t0, -180, 190, 0.5) %>%
mutate(frame = x)
}) %>%
plyr::rbind.fill()chart <- ggplot(terminatorLatLon, aes(frame = frame)) +
borders("world", colour = "gray90", fill = "gray85") +
geom_ribbon(aes(lat, ymax = lon), ymin = 90, alpha = 0.2) +
coord_equal(xlim = c(-180, 190), ylim = c(-58, 85), expand = 0) +
theme_map()gganimate(chart, interval = 0.1, ani.width=1000, ani.height=600, filename = "terminator-animation.gif")
```