Code Monkey home page Code Monkey logo

terminator's Introduction

terminator

This is a simple R port of the Leaflet plugin Leaflet.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

Produced like so:

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

terminator's People

Contributors

jogall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

terminator's Issues

Rcpp version

As noted on Twiter: rly nice port!

I took it one step further: https://github.com/hrbrmstr/terminator

Reaching out to see how far you were going to go with it and even suggest that I transfer the repo over to you (or add you as a collaborator on to my Rcpp port).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.