KML, Keyhole Markup Language) contains geospatial information in XML notation. Files saved as KML can be opened in Geographic Information System (GIS) applications provided they support it. Many applications have started providing support for KML file format after it has been adopted as international standard. KML uses a tag-based structure with nested elements and attributes. All the tags are case-sensitive and the order of these tags, as per KML Reference, is important to follow.
KML was originally developed for use with Google Earth which was originally known as Keyhole Earth Viewer. KLM was adopted as international standard in 2008 by the Open Geospatial Consortium in 2008. Since the format was developed for use with Google Earth, it has the distinction to be the first one to view and edit KML files. With the passage of time, there are now more and more projects that provide support for KML file formats including several APIs in different languages.
KML File Format Specifications
The KML Reference is a complete guide for referring in order to have the full file format specifications. A standard KML file consists of:
Descriptive HTMLin Placemarks
In addition to these, an advanced version of KML file can have:
Styles for Geometry
Styles for Highlighted Icons
Each of the KML element has lat-long information that geo-locates the information present in the file. However, there can be additional parameters as well like heading, altitude and tilt.
It is used to represent a position on Earth’s surface and is identified by the element. Following is an example how a placemark is represented in KML file.
<description>Attached to the ground. Intelligently places itself
at the height of the underlying terrain.</description>
Descriptive HTML in Placemarks
Additional information can be associated with a placemark that further enhances the representation of the placemark. Such information includes links, font sizes, styles, and colours. In addition, it also includes text alignment and tables to be part of the placemark.
<h1>CDATA Tags are useful!</h1>
<p><font color#"red">Text is <i>more readable</i> and
<b>easier to write</b> when you can avoid using entity
These represent the layering of an image onto the Earth’s surface. The elment contains the link to the overlay image file.
<description>Examples of ground overlays</description>
<name>Large-scale overlay on terrain</name>
<description>Overlay shows Mount Etna erupting
on July 13th, 2001.</description>
Paths are represented by element that is a collection of lat-long pairs. Using these, many different types of paths can be created in Google Earth.
<description>Examples of paths. Note that the tessellate tag is by default
set to 0. If you want to create tessellated lines, they must be authored
(or edited) directly in KML.</description>
<description>Transparent green wall with yellow outlines</description>
Spatial Referencing in KML File
Information contained in any Geospatial file about Geo-Locations can have different meanings without spatial referencing information. By default, the spatial referencing of KML file are defined by the World Geodetic System of 1984, WGS84.