So then I looked around to see if anyone had written code to help people convert Matlab data into Google Earth files. The Google Earth Toolbox (recommended by my colleague Amir) worked great. It allows you to display data using functions very similar to standard Matlab functions (eg. imagesc()) only the output image is projected onto the planet and can be explored using Google Earth. The image above is a map of the tropical cyclone climatology that I imported to Google Earth with only two lines of code.

A = ge_imagesc(LON, LAT, flipud(DATA));ge_output('FILENAME.kml', A);

[As indicated, the only bug I found was that some of the functions flipped the data vertically, which is easy to fix with one usage of the function flipud().]

It seems to me that one huge advantage of this presentation method is that pretty much anybody can view and explore global data-sets, since the interface is entirely intuitive and requires no manipulation (similar, in many respects to the contribution of Gapminder).

With a little extra work, I made the data-set dynamic in Google Earth, so that users can view data from different dates using a slider (see code below), and made this movie for use in presentations:

Below the fold is the script I used to make a Google Earth data set that changes over time. Making the movie above required two additional steps.

Add a "Tour" in Google Earth (under "Add") which just records your browsing of your data in a movie that plays back in the Google Earth Application.

Use a screen capture program to record that movie as it plays back. (My friend Pam recommended this screen capture software, which works nicely and is easy to use).

UPDATE: SINCE I'VE REPEATED THIS PROCESS A FEW TIMES NOW, I'VE WRITTEN A FUNCTION IN MATLAB THAT GENERATES THE GOOGLE EARTH FILE. ITS SIMILAR TO THE SCRIPT BELOW, BUT IS EASIER TO USE FOR AN ARBITRARY DATASET. DOWNLOAD IT HERE.

3 comments:

The form of the dataset for both this script and for the more general code posted here is:

DATA - M x N x T array of data, where each M x N layer describes data that occurs simultaneously at a moment in time. The third index is the index for the time variable (years). lat - M x 1 vector describing the latitude of the M rowslon - N x 1 vector describing the longitude of the N rows

In the script above, there are also the scalar variables

NUMBER_YEARS - just TSTARTING_YEAR - the year associated with DATA(:,:,1)

YEARS - T x 1 vector with year values (eg. 1995, 1996…) that match the T layers in DATA

in both files, you also need to specify the strings FILENAME and LAYER_NAME (VARIABLE_NAME in the function). The former is the name of the file it writes out, the latter is the name of the layer that will show up in google earth.

I am trying to do something very similar but with precipitation data, however when I do the animation the stars in google earth also move with the time span slider and it is quite dizzying so I was wondering how you removed the stars from your movie? Thank you