What Is Keyhole Markup Language (KML)?
Keyhole Markup Language (KML) is an XML-based file format used to represent and visualize geographic data in two-dimensional maps and three-dimensional Earth browsers. Originally developed by Keyhole, Inc. for use in its Earth Viewer software—which later became Google Earth—KML was adopted as an international open standard maintained by the Open Geospatial Consortium (OGC) in 2008. This article explains the fundamentals of the KML specification, how it utilizes XML to structure geographic features, its primary components, and its role in modern geographic information systems (GIS).
The Role of the Open Geospatial Consortium (OGC)
The Open Geospatial Consortium is an international standards organization that ensures geospatial content and services are interoperable across different platforms. When Google submitted KML version 2.2 to the OGC, the consortium established it as an official standard. Under OGC governance, KML specifications are maintained and evolved to ensure long-term compatibility, vendor neutrality, and seamless integration among diverse mapping software, mobile applications, and web services.
How KML Uses XML
KML is built entirely on the Extensible Markup Language (XML) standard, meaning all data is stored as human-readable, plain-text code using nested elements and tags. Each tag describes a specific geographical feature, attribute, or visual behavior.
A standard KML document begins with standard XML declaration headers
and encloses all spatial data within a root <kml>
element. Because it uses XML syntax, KML can be easily generated,
parsed, edited, and validated using standard text editors and
programming libraries.
Core Features and Elements in KML
The KML specification provides a wide variety of tags to describe spatial objects, styling, and navigation:
- Placemarks (
<Placemark>): The fundamental building block in KML used to define a geographic feature, such as a point of interest, line, or area. - Geometries: KML supports multiple geometry types,
including
<Point>(latitude, longitude, and altitude),<LineString>(paths and tracks), and<Polygon>(enclosed areas). - Overlays: Users can superimpose raster imagery
directly onto the terrain (
<GroundOverlay>) or pin static graphics like logos and legends to the screen viewport (<ScreenOverlay>). - Styles (
<Style>): Customizes the visual presentation of features, allowing control over icon graphics, line thickness, fill colors, and label typography. - Camera Controls (
<LookAt>and<Camera>): Defines the exact perspective, tilt, heading, and altitude from which the viewer observes a geographic feature. - Time and Animation (
<TimeStamp>and<TimeSpan>): Enables historical data tracking and animated timelines by associating time data with geographical changes.
KML vs. KMZ
KML files are often distributed in a compressed format known as KMZ.
A KMZ file is a standard ZIP archive containing a main
doc.kml file along with any referenced local assets, such
as custom icons, 3D model files (COLLADA format), and ground overlay
textures. This packaging simplifies sharing, reduces file sizes, and
ensures that all associated visual resources remain bundled
together.
Practical Applications of KML
KML serves as a universal format for sharing geographic information across commercial and open-source platforms. Common uses include:
- Visualizing spatial data within Google Earth, Google Maps, and ArcGIS.
- Exporting GPS track logs and waypoints from mobile apps and outdoor navigation devices.
- Distributing interactive scientific data, such as weather patterns, earthquake epicenters, and demographic heat maps.
- Creating scripted, interactive virtual tours of landscapes and urban environments.