Do enjoy it in full screen. If you are here just for the action, you may want to skip past the first couple of minutes.
This post will be something in between a product review and a collection of points of reference that may be of use to anyone tempted by the idea of using Google Earth for data visualisation. The workflow described in this post is less than ideal, but perhaps this can still be useful as a starting point for someone considering to give it a spin.
In order to use Google Earth Studio, some familiarity with video editing software will be useful. Their own documentation is mandatory reading to to get started. Taking the time to get some basic understanding of how camera movement works in the online interface will spare much frustration going forward.
If you have data in the format used by Google Earth (.kml), or already know how to convert data into it, you can skip the following section detailing how to convert data to .kml with the R programming language. If you are unfamiliar with R, but still want to read more about Google Earth Studio, you will also probably want to skip the following section.
Getting the data into Google Earth
Exporting geographic datasets from R into a format that can be used in Google Earth Studio and customising their appearance is not a straightforward process, at least in part due to the scarcity of dedicated documentation and tutorials. Not all features of kml files are accepted by Google Earth, and none of the major packages for geocomputation with R have dedicated functions aimed at facilitating export from R to kml. After somewhat struggling with plotKML, I decided to fall back on a package that will be much more familiar to anybody using geographic data in R: sf (if you are unfamiliar with analysis of geographic data in R, the book Geocomputation with R is a great point of reference).
sf makes it easy to get data into R and process them, but leaves data export to other libraries, in this case libkml via rgdal with some customisation available through ogr_style. These are all documented, but do not interoperate smoothly, and one is left figuring out via trial and error which parameters will successfully make their way from the sf object to the exported kml. Some parameters seem to get lost between ogr_style and libkml, some kml features are not recognised by Google Earth, and troubleshooting is complicated by the fact that it requires some familiarity with the different underlying standards involved.
In the end, I made a couple of convenience functions that allow for exporting sf objects into kml files, facilitating basic customisation such as line and fill colour, text size, and such, using available export functions. When I could not get those producing the desired result, I reverted to processing bare xml. This now all happens under the hood with the dedicated functions that are now part of the latlon2map package.
Another complicating factor came from the fact that in Google Earth text labels are supposed to always be accompanied by a symbol (by default, this is an ugly yellow pushpin). Unfortunately, there is no easy way to disable symbols. A workaround is to set the scale of the symbol to 0, but the text will still appear on the top-right corner of the given coordinates. I have not found a way to have them centre-aligned, so I ended up manually adjusting the location of the points to give the impression that the label is at the centre of a given shape — in this case, at the centre of a given grid cell (see the code for details).
Besides, there is not an obvious way to change the altitude of geographic object in sf, which is sometimes necessary when working with Google Earth Studio for the reasons described in the next section. Eventually, I ended up converting the sf object to a matrix, add elevation, convert back to sf, add parameters to be included in the kml to clarify how that information on altitude is to be used (available options include relativeToGround, absolute, relativeToSeaFloor), and finally export to a kml file that can be read by Google Earth.
mutate(Z = 50) %>% # here is setting the height to 50 meters
st_as_sf(coords = c(“X”, “Y”, “Z”), dim = “XYZ”) %>%
summarise(geometry = st_combine(geometry)) %>%
extrude = TRUE) %>%
Once you know how to go about it, this looks quite interesting and powerful, as height can potentially be used for visualising data. After some further random tests (see picture), considering to include in the video some 3D bar charts, and only barely resisting the temptation of writing a tutorial on making 3D pie charts in Google Earth Studio, I was finally able to move on.