R animation: great circles 3, final draft

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:


R + htmlwidgets + DT + sparkline

Here are some examples with code where I use the R packages DT and sparkline to produce interactive data tables and inline graphs as well as inline graphs within data table cells. Both packages utilize the htmlwidgets package to interface with javascript libraries. With htmlwidgets you can create custom widgets to use specific javascript libraries to display your data from R on the web. I used the above packages along with rmarkdown to make a markdown document containing the example widgets and code, but you can also use widgets within Shiny apps.


R plot: Comparison of Fairbanks, Alaska and Beijing, China air quality

Here’s an interesting R plot comparing a specific air pollution metric between Fairbanks, Alaska and Beijing, China. Right off the bat, Beijing obviously has far worse air quality, and more significantly, it is a chronic, daily problem. But it is used for comparison because we already know this is the case.

In Fairbanks, while air quality is known to decrease in very cold weather and the seasonal cycle of winter spikes in the particulate are clear in the plot, this is nothing compared to Beijing’s daily levels year round. On the other hand, lots of summertime smoke from boreal forest fire in interior Alaska can make Fairbanks air quality just as bad as Beijing’s if not worse. This can be seen in 2004, which was a year of record fires in Alaska. 2015 has also been a big fire season, apparent in the plot as well.


Lightning strike trend prediction with GBM in R

Lightning activity is projected to increase with climate change. Lightning activity is interesting to model with stochastic gradient boosting (GBM: generalized boosted regression models/gradient boosting machine) in R. One use I have for this at SNAP is in the context of landscape fire modeling with SNAP’s ALFRESCO model. The simulations from the model can be enhanced by incorporating information about lightning strike activity over Alaska which varies both spatially and temporally.


Climate projections by cities: R + Shiny + rCharts + leaflet

I have approached a final draft of my Community Charts version 4 Lite, now with leaflet map integration. This R Shiny web application shows projected climate trends for various Alaska and western Canada communities. Note that if no other users are already connected to the app, it will take a moment (maybe ten seconds?) to load the initial data set into the global environment, but there is an indicator bar at the top of the screen in this case.

The graphing is done with the rCharts package and the graphs now have responsive width. The interface is much cleaner after removing the screen space-wasting bootstrap button groups from prior versions in favor of drop down menus. The key addition this helped make room for is an interactive map which I incorporated into the app using the leaflet package. Like the Shiny package, the leaflet package is also by RStudio. It makes using leaflet through R quite easy. Full app source code is available.


Syncing a leaflet map and a selection menu with event observation

I already had a menu for typing/selecting a community for graphing climate trends. What should happen if I suddenly add a competing widget, in this case a leaflet map, for selecting a community? The cool thing about the leaflet map within the Shiny app is that I can use it as an alternative to the community selection menu without having to replace the menu. The user now has an option of how they want to provide location input. Of course, some conflicts do need to be resolved. Having two different input controls for selecting the same thing is obviously problematic if not done right. What happens if I select community A from the dropdown menu and then click on a circle marker in the map to select community B?


Animated great circles 2: smoother lines

Here is draft two of my great circle arcs R animation. This time I focused on improving the smoothness of the lines and removing some buggy line behavior, keeping it on a flat map for now. As with DRAFT 1, the YouTube video is of significantly reduced quality, to the point that you will see zero improvement. It’s really not even worth watching there. A much higher quality source video is available here. It can be downloaded (~90 MB) and viewed locally using a standard video player such as VLC.

Here is the YouTube version if you must:


Animated paths in R: toy example

Recently I have shared examples of animations made using R which feature traversal of pathways, specifically grid cell borders and great circle arcs. Here I provide the basic code required to generate a path sequence from a path.



Get every new post delivered to your Inbox.

Join 364 other followers