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:
http://earth.google.com/kml/
http://earth.google.com/userguide/v4/tutorials/
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="http://earth.google.com/kml/2.1">
and end by with a closing kml tag:
</kml>
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
Example
modis.kml
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<Folder>
<GroundOverlay>
<name>MODIS steam plume</name>
<visibility>0</visibility>
<LookAt>
<longitude>-152.6659616588421</longitude>
<latitude>59.00315632745851</latitude>
<altitude>0</altitude>
<range>334944.723968608</range>
<tilt>42.37613018389006</tilt>
<heading>137.6356988109601</heading>
</LookAt>
<color>96ffffff</color>
<Icon>
<href>http://squarepeg.net.images.alaska.edu/googlearth/augustine/MODIS_051212.2216.t1.jpg</href>
</Icon>
<LatLonBox>
<north>62.57693689340542</north>
<south>56.70777850238971</south>
<east>-147.4841738823949</east>
<west>-157.9991011579873</west>
<rotation>3.941674422370856</rotation>
</LatLonBox>
</GroundOverlay>
</Folder>
</Document>
</kml>
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.
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:
http://earth.google.com/kml/index.html
Google Earth Blog basics:
http://www.gearthblog.com/basics.html
Google Earth Users Blog:
http://googleearthuser.blogspot.com/