GLG410--Computers in Earth and Space Exploration


Announcements Syllabus Schedule Weekly lecture notes Assignments Links

Using KML to Import Points and Image Overlays into Google Earth

Basic Links

Google Earth
KML Documentation
KML Tutorial
Lat Long Blog

Things to remember

KML is the Keyhole Markup Language--items are tagged just like in HTML.
KMZ is a compressed (.zip) kml plus any images.
You can add KMLS to Google maps using the MyMaps capability

KML Introduction - Importing Points to Google Earth

A Placemark is one of the most commonly used features in Google Earth. It marks a position on the Earth's surface, using a yellow pushpin as the icon. For our example, we will use the Yellowstone Earthquake data with which we worked so much at the beginning of the semester. Here is the Yellowstone Earthquake file.

Let's start with the simplest placemark:


http://arrowsmith410-598.asu.edu/Lectures/Lecture25/eq1.kml

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name> 3.4 </name>
<Point>
<coordinates>-110.46,44.47,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
The structure of this file breaks down as follows:
An XML header. This is line 1 in every KML file. No spaces or other characters can appear before this line.
A KML namespace declaration. This is line 2 in every KML 2.2 file.
A Placemark object that contains the following elements:
A name that is used as the label for the Placemark
A description that appears in the "balloon" attached to the Placemark
A Point that specifies the position of the Placemark on the Earth's surface (longitude, latitude, and optional altitude)

How about changing the icon?

http://arrowsmith410-598.asu.edu/Lectures/Lecture25/eq2.kml

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Style id="dot">
<IconStyle>
<scale>0.5</scale>
<Icon>
<href>http://arrowsmith410-598.asu.edu/Lectures/Lecture25/dot1.png</href>
</Icon>
</IconStyle>
</Style>
<Placemark>
<name> 3.4 </name>
<styleUrl>#dot</styleUrl>
<Point>
<coordinates>-110.46,44.47,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>

Let's change what goes in the pop up when you click on it:



http://arrowsmith410-598.asu.edu/Lectures/Lecture25/eq3.kml
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Style id="dot">
<IconStyle>
<scale>0.5</scale>
<Icon>
<href>http://arrowsmith410-598.asu.edu/Lectures/Lecture25/dot1.png</href>
</Icon>
</IconStyle>
</Style>
<Placemark>
<name> 3.4 </name>
<description> <![CDATA[<h1>Yellowstone EQs</h1><p><font color="red">Year = 1973.00 Depth = 10.00 Mag = 3.40.</font></p>]]></description>
<styleUrl>#dot</styleUrl>
<Point>
<coordinates>-110.46,44.47,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>

Now how about the entire dataset?



http://arrowsmith410-598.asu.edu/Lectures/Lecture25/eq4.kml
Basically it is the same as above, we just repeat the placemark tag, changing the location and attributes: <Placemark>
<name> 3.4 </name>
<description> <![CDATA[<h1>Yellowstone EQs</h1><p><font color="red">Year = 1973.00 Depth = 10.00 Mag = 3.40.</font></p>]]></description>
<styleUrl>#dot</styleUrl>
<Point>
<coordinates>-110.46,44.47,0</coordinates>
</Point>
</Placemark>

Here is the Matlab script that does it: yeqs.m

Image Overlays

Another feature you may want to test drive in Google Earth is the ground overlays. These are images (in BMP, GIF, TIFF, TGA, and PNG formats) can be "draped" over the landscape. We will again use the Yellowstone Earthquake data to demonstrate how some of our images we have made can be imported into Google Earth.

Remember our color image of mean earthquake depth:



The first thing we need to think about is "how do we georeference our image". We will need to define the EXACT bounding box for the image. To make this easier, I will constrain my figure to the borders of my axis.

We used the following script to generate the figure above: mean_depth_pcolor.m

From this script, we learn that the bounding box of the figure is:
East: -109.99
West: -110.99
North: 44.92
South: 44.02

Place the figure in Google Earth as a ground overlay

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<GroundOverlay>
<name>Yellowstone Eq Mean Depths</name>
<Icon>
<href>./pcolor2.jpg</href>
</Icon>
<LatLonBox>
<north>44.92</north>
<south>44.02</south>
<east>-109.99</east>
<west>-110.99</west>
<rotation>0</rotation>
</LatLonBox>
</GroundOverlay>
</kml>

New tags for overlays that were not in the last section.
A GroundOverlay object contains the following new elements:
An Icon contains href which links the image for the overlay.
A LatLonBox specifies where the top, bottom, right, and left sides of a bounding box for the ground overlay are aligned.

Turn on the earthquakes to fill out our points and overlay


A more complex kml for teaching geologic hazards: GLG110Update_2004_Tsunami_videos.kml (put into google maps).

Other KMZs of high resolution topography are here: OpenTopography kmls.

Arc into KML

ArcGIS 9.3 includes export and conversion to KML. You can find the functionality under ArcToolBox->Conversion Tools->To KML->Map to KML:



This tool converts a map file (MXD file) to a kmz. The scale setting tells it to show the image at that scale and larger (i.e., more zoomed in). Making a single composite image collapses layers in the MXD file to a single image in the KML file.


This works similarly in Arc10. The quality of the output rasters in the kml is not very good (See this thread). The trick is to use superoverlays and regions: http://code.google.com/apis/kml/documentation/regions.html.

Video explanation for ArcMap 10:


Last modified: November 23, 2015