18 Jul 2013


This is an initial implementation of a package that provides R users with high-level facilities to generate KML, the Keyhole Markup Language for display in, e.g., Google Earth. By high-level, we mean that the R user does not have to (but can) create the XML directly herself. Instead, there are high-level functions which take care of these lower-level details.

The package is intended to provide the basics and illustrate how others can build on this framework to add more functionality and allow other users to leverage more of the KML facilities. As such, the package is far from a complete interface to KML, but more a proof-of-concept and an encouragement for statisticians to explore this rich form of visualization. We will add to the package as time permits and we need to for our own use. We strongly encourage others to build on this, contribute code back or take over the package if they are intending to do much work in this area. Please chat with us via email to let us know about your plans so we can help and coordinate with others.

The main elements the package provides are the high-level kml() function, and the slightly lower-level/more-specific functions kmlPoints() and kmlTime(). kmlPoints() displays points on the earth. kmlTime() displays points but connects them with lines and puts a time stamp on each.

These functions need to know the variables that correspond to longitude, latitude and time. One can change the names of the variables in the data set, or more conveniently and richly use a formula notation. The formula is something like

  ~ X + Y @ timeVariable
This is not comprehensively implemented yet in terms of allowing transformations of the variables within the formula, but we will do this in the future. This notation will also support an expression on the right hand side and conditioning and this can be used for various interesting effects.

There are more nuts-and-bolt functions for creating specific KML elements.


  • Four new annotated examples presented at the JSM 2011
    A collection of examples based around Global and Regional Circulation (Climate) Model data. These illustrate polygons as placemarks, animation over time with images and polygons, synchronized animation in a pair of embedded Google Earth plugins in a Web page, and a slider changing the color of polygons in GE.
  • Elephant Seal travels
    Deb Nolan's visualization of the travels of an elephant seal. Data from David Brillinger and Brent Steward
  • Norwegian Harp Seal
    Data from the argosfilter package.
  • Seaos seal paths
    Yet more seals! This is from the Seaos project at St. Andrews. This uses the seals to sample the ocean characteristic.
  • Average temperatures in 100 US cities in January, April, July and October.
    This illustrates drawing time series created by R on Google Earth at specific locations and also allowing the user to control time. The colors show the temperature, the flatness or peakedness illustrate the variability. Clicking on a city also shows the data for the city as a table and a larger version of the plot.

    There are many ways this could be improved. Try some!

    See here for more details

  • US Cities
    A view of ~ 1200 US cities merely displayed at their locations on Google Earth with a minimal description provided giving the city name and state.
  • The code to generate these are in the package in the tests/ directory. This is the best place to look for working examples of different features. The examples in the Rd files may not be as comprehensive until I move the code from the tests to the Rd files.


    Changes to the package
    Duncan Temple Lang <duncan@wald.ucdavis.edu>
    Last modified: Tue Aug 2 08:04:58 PDT 2011