Keyhole Markup Language (KML)

What is KML?

KML stands for Keyhole Markup Language. It is an XML-based language for managing three-dimensional geospatial data in Google Earth, Google Maps and Google Mobile. It is also partially supported by other virtual Globe programs (e.g., NASA World Wind, ESRI Arc Explorer). KML is an OGC best practice and is in the process of becoming an open standard.

Examples and documentation on KML can be found on the official Google Earth webpages:


Authoring KML

You can open a KML file with any text editor, such as Microsoft Word or Notepad on a Windows computer or vi on a Unix system. However, it is best to use a text editor that is designed for editing markup languages. If you copy and paste the sample KML code below into a text editor and save the file with a .kml extension and with UTF-8 encoding, then you will create a KML file. When creating your own KML file it must start with standard header lines:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="">

and end by with a closing kml tag:


KML Elements

Between the KML designation tags are placed one or more elements that relate to various features and functionality that can be create. A schema for the correct classification of these elements is shown below for KML 2.1:



Note that abstract elements (shown in italics and in dotted boxes in the diagram) are not actually used in KML files. They are a useful way for a single element to serve as the programmatic foundation for multiple similar (but different) derived elements, e.g., <Document> and <Folder> are types of container, they can co-exist separately with a single KML file, and/or be contained within each other.

Note: Element names (contained within <>) are case sensitive



<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="">
        <name>MODIS steam plume</name>

Note: Comments within KML code are indicated by <!-- Comments -->

Learning KML

The following exercises act as an introduction to the major elements of KML and how to author files that utilize them. They are best followed sequentially.

  1. Navigation
  2. Data Points
  3. Organization
  4. Touring
  5. Applying Styles
  6. Images
  7. Dynamic Updating
  8. 3D models
  9. Animation

Hints and help are given where the symbol is seen. Links to examples of more advanced KML are given at the end of the sections, and are meant for further exploration after completing the 9 exercises. Further KML help can be found at:

Google's KML documentation:
Google Earth Blog basics:
Google Earth Users Blog: