We’ve looked before at how you can annotate geographical maps using R, but what if you want to overlay data onto a globe of the Earth, using Google Earth? The RKML package for R (from the OmegaHat project) allows you to do just that, by providing a high-level interface from R to generate KML files, which in turn are used to drive animations in Google Earth.
Here’s one very cool example of its use: at the blog Mind of a Markov Chain you can find an animation of the Deepwater Horizon oil spill, overlaid with the tracks of tuna migrations. Here’s a screenshot:
Follow the link below for the animation, where you’ll see that the migration paths intersect with the spill (in both time and space). This animation was created with fewer than 30 lines of R code, which you can also find at the link.
Mind of a Markov Chain: R and Google Earth ~ comparing tuna tracks vs. Gulf of Mexico oil spill extent