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.

cc4liteFinal

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?

(more…)

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:

(more…)

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.

(more…)

Updated climate projections by cities

[Alpha] and [beta] versions of a simple R Shiny web application showing projected climate trends for various Alaska and western Canada communities is available. [The alpha and beta versions are currently nonfunctional. But you can skip to the final version here. Some of the text below only pertains to the alpha and beta versions. See the new post regarding the final version.] Since this probably sounds like the hundredth rendition of the same thing to regular blog readers, I’ll just mention that this offers some updated data, downscaled CRU 3.2 and CMIP5 global climate model outputs.

cc4lite2

(more…)

Animated great circles 1: flat map to 3D Earth

More fun with great circle arcs. Who doesn’t love a good great circles graphic? This time, however, it is an animation. Using R, not only have I animated path traversal along great circle arcs, but I’ve also projected them onto a three dimensional global surface. It was not without its challenges. And yes, the title indicates there will be more and better to come.

With the high number of thin, rapidly moving arcs, and color and transparency shifts from frame to frame, this video essentially also serves as a demonstration of ways in which a video can be significantly reduced in quality when re-encoded on upload to sites like YouTube and Vimeo for streaming purposes. A much higher quality source video is available here. It can be downloaded (~100 MB) and viewed locally using a standard video player such as VLC.

(more…)

R Shiny App: Alaska Sea Ice Edge

A simple app for mapping estimates of Alaska sea ice edge during different months, years, and decades is now formally available. I made this app in R about six months ago and shared an earlier version on Twitter. I have cleaned up the code a bit. Most notably, it now offers somewhat more adaptive color options for a variable number of factor levels.

AK Ice Edge

R Shiny apps upgraded to Bootstrap 3

All of my Shiny apps have been upgraded to Bootstrap 3 now that this is available in the Shiny package. The apps have also been relocated from their temporary home on RStudio’s Spark server to SNAP. Most people have been using and referencing the permanent SNAP urls, which redirected to Spark previously, but which are now pointing to SNAP again. Nevertheless, the Spark urls have propagated about the internet a bit. Please make sure to stick with shiny.snap.uaf.edu/appName/ url format.

A convenient place to access all my publicly available apps is my leonawicz.github.io page. There are a couple apps there which you cannot run (run_alfresco and cmip3_cmip5, specifically) because they are only available from within the university domain. However, the vast majority of the apps are public, and for those few which are not I still include them in the page so that you may access the R code on Github. These still show a “Launch” button. I will tidy that up soon to remove any confusion.

Follow

Get every new post delivered to your Inbox.

Join 318 other followers