Here is the final draft of my great circle arcs R animation. I made this back in January shortly after my first two drafts, but am only now getting around to sharing it, which is a typical representation of how seldom I can make time for blogging. But given the recent spike in interest (thanks to Urban Demographics for sharing my work) in the first, and roughest, draft, I am motivated to finally share something better.
As with DRAFT 1 and DRAFT 2, the YouTube video upload is of significantly reduced quality compared to the original render. As I’ve said in the previous posts, it’s really not even worth watching on YouTube.
A much higher quality source video is available here. It can be downloaded (~365 MB) and viewed locally using a standard video player such as VLC. Here is a screenshot taken from source as an example:
mapmate (map animate) is an R package for map animation. It is used to generate and save a sequence of plots to disk as a still image sequence intended for later use in data animation production.
mapmate package is used for map- and globe-based data animation pre-production. Specifically,
mapmate functions are used to generate and save to disk a series of map graphics that make up a still image sequence, which can then be used in video editing and rendering software of the user’s choice. This package does not make simple animations directly within R, which can be done with packages like
mapmate is more specific to maps, hence the name, and particularly suited to 3D globe plots of the Earth.
This introduction covers the following toy examples. Generate a sequence of still frames of:
I have posted a new R data animation video. It’s an example animation of modeled historical and projected global temperature change from 1850 – 2100. The data prep, analysis, full processing and generation of all sets of still frames for each layer in the video are done using R.
Typically an ensemble of models would be used but this video is just to demonstrate a basic animation using one climate model, both with a monthly time series and a monthly 10-year moving average time series. If wondering about the y-axis range, the animation shows anomalies, or delta change, from the climate model’s historical baseline monthly average temperatures using a given climatology window.
In a later video I will use annual and seasonal averages, which will display a smoother signal than monthly series.
Here I share R code I used to produce animated great circle arcs on top of a rotating 3D Earth. The code is not entirely reproducible but you should be able to use what is shared here to create your own video frames given your unique data and computing environment and resources.
The WordPress blog is not the most elegant for displaying lots of code so go to the original full post.
When I make great circle animations, at the core of the process is always an R function that transforms a series of coordinates describing points along a great circle arc into multiple series of great circle arc segments. The goal is simple: plot a series of line segments, saving each plot as a subsequent still frame, rather than plotting the original entire arc as a single plot. The input is generally a data table (much faster to work with than a data frame if you have a lot of data) with longitude and latitude columns where the coordinates in each row describe a subsequent point along one of my paths. I also use a third column to provide a unique group ID for each path to keep them distinct.
For the blog readers, just a quick heads up that I have posted a new R data animation to YouTube. A complete post will follow, but for now here is the video. It displays the social network of SNAP Shiny app users over about the past year and a half using great circle trajectories on a rotating 3D Earth. It’s best in 1080p, but still somewhat degraded for streaming. I’ll post the raw source video later as well, which is crystal clear.
I used geolocation data from Google Analytics. I routed all the traffic randomly through either Fairbanks, AK or Denver, CO to complete the network since those two places best describe where my apps come from. It’s great to see how many people connect to the apps and from where; too many people to plot as a single static graphic without some of the essence of the data being lost.
As usual, the still frames of the rotating globe, its surface texture, country boundaries and great circle paths are all made in R. It’s basically a series of plots made with ggplot2.
Using leaflet in R is fairly simple and there are plenty of online resources and examples available already. See the RStudio tutorial to get started if you haven’t already. This post presents a series of examples which build upon each other.
The code displays both point data and raster data on leaflet maps with Shiny app integration. The focus here is to show the utility of event observation on the server side for integrating the behavior of browser elements, namely, the leaflet map.
In the course of these examples, I’ll also use a modal from the shinyBS package and the maps will be full size in the browser window with UI widgets laid on top using absolute panels. The full post contains interactive embedded Shiny widgets. See the full post here. It includes complete source code for these and other related apps using leaflet.
In this post I share an R Shiny app which uses the leaftlet package for interactive maps. This app differs from prior apps I’ve made featuring leaflet maps. First, it displays rasterized map data rather than just point layers. Also, longitude and latitude sliders in the browser allow for cropping the map. Additionally, the user can upload a shapefile to crop and mask the rasterized data overlays in the leaflet window to the specific spatial data they wish to work with, and then extract and download that data.
Here are some examples with code where I use the R packages
sparkline to produce interactive data tables and inline graphs as well as inline graphs within data table cells. Both packages utilize the
rmarkdown to make a markdown document containing the example widgets and code, but you can also use widgets within Shiny apps.