XML - Managing Data Exchange/Google earth

Previous Chapter Next Chapter
OpenOffice.org & OpenDocument Format acord

KML Introduction


(most content here is directly quoted from the KML wikipedia article)

KML (Keyhole Markup Language) is an XML-based Markup language for managing the display of three-dimensional geospatial data in the programs Google Earth, Google Maps, Google Mobile, ArcGIS Explorer and World Wind. (The word Keyhole is an earlier name for the software that became Google Earth; the software was produced in turn by Keyhole, Inc, which was acquired by Google in 2004. The term "Keyhole" actually honors the KH-11|KH reconnaissance satellites, the original eye-in-the-sky military reconnaissance system now some 30 years old.)

The KML file specifies a set of features (placemarks, images, polygons, 3D models, textual descriptions, etc.) for display in Google Earth, Maps and Mobile. Each place always has a longitude and a latitude. Other data can make the view more specific, such as tilt, heading, altitude, which together define a "camera view". KML shares some of the same structural grammar as Geography Markup Language|GML[1]. Some KML information cannot be viewed in Google Maps or Mobile [2].

KML files are very often distributed as KMZ files, which are Data compression|zipped KML files with a .kmz extension. When a KMZ file is unzipped, a single "doc.kml" is found along with any overlay and icon images referenced in the KML.

Example KML document:

 <?xml version="1.0" encoding="UTF-8"?>
 <kml xmlns="http://earth.google.com/kml/2.0">
   <description>New York City</description>
   <name>New York City</name>

The MIME type associated to KML is application/vnd.google-earth.kml+xml.
The MIME type associated to KMZ is application/vnd.google-earth.kmz .

Basic KML Document Types


For an XML document to recognize KML specific tags you must declare the KML namespace (listed below).

<kml xmlns="http://earth.google.com/kml/2.0">

You will see this declaration in all the example files listed.

In order to see use the examples provided in this chapter you will need to copy and paste the text into any text editor. Next you will save the file as a .kml. This can be done by choosing "save as" and naming the file with a .kml extension (You might have to surround the name in quotes ie "test.kml").



Placemarks simply make a clickable pinpoint inside Google Earth at an exact location based on coordinates. This can be useful for marking a point of interest or a beginning and ending destination to a trip.

The example KML document in the introduction uses the Placemark tag. If you want to move the placemark to a different location all you would change are the coordinates.



Paths are a series of connected coordinates that can be edited with line styles for a more bold appearance inside Google Earth. The height and color can be adjusted for a more exaggerated appearance and better clarity.

The following example is a path from Atlanta, Georgia to Nashville, Tennessee. The code may look a bit complicated but it is mostly just styling/formatting tags with the 4 actual coordinates at near the end. So if you wanted to use the same style wall but just make a different path, all you would do is change the coordinates.

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">

    <description>Path from Atlanta to Nashville</description>

    <Style id="yellowLineGreenPoly">

      <name>Atlanta to Nashville</name>
      <description>Wall structured path</description>




Overlays are graphics that can be placed over an area in Google Earth marked by coordinates. These graphics can show how an area looked at a different point in time or during a special event (like a volcanic eruption).

This overlay example comes from Google's KML samples webpage and shows what Mt. Etna looked like during an actual eruption.

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
    <name>Ground Overlays</name>
    <description>Examples of ground overlays</description>
      <name>Large-scale overlay on terrain</name>
      <description>Overlay shows Mount Etna erupting 
          on July 13th, 2001.</description>

You can see from the code that it takes the image etna.jpg and places it over the coordinates listed.



Polygons are a neat feature of Google Earth that allow 3-D shapes to be molded anywhere in Google Earth. These shapes can be useful for making neat presentations or just showing the world a structure actually looks.

This example is a polygon of Turner Field (The Atlanta Braves' home stadium) in Georgia. There is no styling on the polygon to keep the code simple.

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">

    <name>Turner Field</name>


As you can see from the code, the polygon's 3-D shape is made up from the latitude and longitude coordinates with the height being determined by the 3rd column value inside the coordinates tag (28 in this case).

Google Earth


Google Earth is the name of Google's free software that is responsible for handling these KML documents. It is a virtual world created by a collage of satellite images where a user can manipulate the Earth in any way to see its landscapes, oceans, and cities.

You can find more information and download the software here.

Basic Interface Navigation


The user interface is fairly straight forward and is extremely easy for computer illiterate users to just jump right in and start exploring. You can completely ignore the toolbars and buttons if you want and just click and grab on the Earth to shake, spin, or roll it as you please. To zoom in, simply right-click and pull down or up depending on the speed which you prefer to "fall" toward the surface.

If you would like help finding a location you can type in the location (in the form of City, State) in the "Fly to.." search box. Google Earth will then spin around and zoom in to the location entered. If you want to take a virtual vacation, Google has some preset locations saved in the window below "Fly to..." labeled "Sightseeing." Simply click on one of these locations and be taken to the location where pictures, articles, and comments can be all be viewed.

Points of Interest


Points of interest that Google has already marked for users are marked with different color dots and icons. These can be clicked on for a variety of information ranging from a simple comment, to a panoramic photograph of that exact location. Advanced users, interested in the code make-up of such a feature, can right click on any of Google's marks and choose "Copy." This will copy all the code for that feature where you can just paste it into a text document to see all of the tags and references.

More References


Other notes


Wikipedia in other languages