Last modified by Farooq Sheikh on 2019/07/17 07:55

What is a KML file?

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.

Brief History

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:

  • Placemarks
  • Descriptive HTMLin Placemarks
  • Ground Overlays
  • Paths
  • Polygons

In addition to these, an advanced version of KML file can have:

  • Styles for Geometry
  • Styles for Highlighted Icons
  • Screen Overlays
  • Network Links

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 <Point> element. Following is an example how a placemark is represented in KML file.

<kml xmlns="">
   <name>Simple placemark</name>
   <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.

<kml xmlns="">
     <name>CDATA example</name>
          <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


Ground Overlays

These represent the layering of an image onto the Earth's surface. The <icon> elment contains the link to the overlay image file. 

<kml xmlns="">
   <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>


Paths are represented by <LineString> element that is a collection of lat-long pairs. Using these, many different types of paths can be created in Google Earth.

<kml xmlns="">
   <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>
   <Style id="yellowLineGreenPoly">
     <name>Absolute Extruded</name>
     <description>Transparent green wall with yellow outlines</description>
       <coordinates> -112.2550785337791,36.07954952145647,2357

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. 


Created by Farooq Sheikh on 2019/07/10 12:49