Wikipedia
Keyhole Markup Language
View on Wikipedia| Keyhole Markup Language | |
|---|---|
![]() | |
| Filename extensions | .kml, .kmz |
| Internet media type |
|
| Developed by | Keyhole, Inc., Google |
| Type of format | GIS file format |
| Extended from | XML |
Keyhole Markup Language (KML) is an XML notation for expressing geographic annotation and visualization within two-dimensional maps and three-dimensional Earth browsers. KML was developed for use with Google Earth, which was originally named Keyhole Earth Viewer. It was created by Keyhole, Inc, which was acquired by Google in 2004. KML became an international standard of the Open Geospatial Consortium in 2008.[1][2] Google Earth was the first program able to view and graphically edit KML files, but KML support is now available in many GIS software applications, such as Marble,[3] QGIS,[4] and ArcGIS.[5]
Structure
[edit]The KML file specifies a set of features (place marks, images, polygons, 3D models, textual descriptions, etc.) that can be displayed on maps in geospatial software implementing the KML encoding. Every place has a longitude and a latitude. Other data can make a view more specific, such as tilt, heading, or altitude, which together define a "camera view" along with a timestamp or timespan. KML shares some of the same structural grammar as Geography Markup Language (GML). Some KML information cannot be viewed in Google Maps or Mobile.[6]
KML files are very often distributed as KMZ files, which are zipped KML files with a .kmz extension. The contents of a KMZ file are a single root KML document and optionally any overlays, images, icons, and COLLADA 3D models referenced in the KML including network-linked KML files. The root KML document by convention is a file named "doc.kml" at the root directory level, which is the file loaded upon opening. By convention the root KML document is at root level and referenced files are in subdirectories (e.g. images for overlay).[7]
An example KML document is:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name>New York City</name>
<description>New York City</description>
<Point>
<coordinates>-74.006393,40.714172,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
The MIME type associated with KML is application/vnd.google-earth.kml+xml; the MIME type associated with KMZ is application/vnd.google-earth.kmz.
Geodetic reference systems in KML
[edit]For its reference system, KML uses 3D geographic coordinates: longitude, latitude, and altitude, in that order, with negative values for west, south, and below mean sea level. The longitude/latitude components (decimal degrees) are as defined by the World Geodetic System of 1984 (WGS84). Altitude, the vertical component, is measured in meters from the WGS84 EGM96 Geoid vertical datum. If altitude is omitted from a coordinate string, e.g. (-77.03647, 38.89763) then the default value of 0 (approximately sea level) is assumed for the altitude component, i.e. (-77.03647, 38.89763, 0).
A formal definition of the coordinate reference system (encoded as GML) used by KML is contained in the OGC KML 2.2 Specification. This definition references well-known EPSG CRS components.[8]
OGC standard process
[edit]The KML 2.2 specification was submitted to the Open Geospatial Consortium to assure its status as an open standard for all geobrowsers. In November 2007 a new KML 2.2 Standards Working Group was established within OGC to formalize KML 2.2 as an OGC standard. Comments were sought on the proposed standard until January 4, 2008,[9] and it became an official OGC standard on April 14, 2008.[10]
The OGC KML Standards Working Group finished working on change requests to KML 2.2 and incorporated accepted changes into the KML 2.3 standard.[11] The official OGC KML 2.3 standard was published on August 4, 2015.[12]
See also
[edit]References
[edit]- ^ "OGC® Approves KML as Open Standard". Open Geospatial Consortium. 2008-04-14. Archived from the original on Nov 30, 2018. Retrieved 2018-11-20.
- ^ "KML". Open Geospatial Consortium. Retrieved 2018-11-20.
- ^ "KML Support in Marble". Marble. Retrieved 2018-11-20.
- ^ "Import from KML. QGIS 2.0 Workshop". Archived from the original on 2025-03-20. Retrieved 2024-12-13.
- ^ "KML layers. ArcGIS Pro 3.4".
- ^ "KML content isn't available in Google Maps". Google Help. Archived from the original on 2016-04-26. Retrieved 2020-01-26.
- ^ "KMZ Files". Keyhole Markup Language. Google for Developers. Retrieved 2009-12-16.
- ^ Wilson, Tim, ed. (2008-04-14). OGC KML. Open Geospatial Consortium, Inc. p. 14. Retrieved 9 June 2015.
- ^ "The OGC Seeks Comment on OGC Candidate KML 2.2 Standard" (Press release). Open Geospatial Consortium. 2007-12-04. Retrieved 2007-12-10.
- ^ Shankland, Stephen (2008-04-14). "Google mapping spec now an industry standard". CNET. Archived from the original on 2008-05-12. Retrieved 2008-04-14.
- ^ "OGC KML 2.3 SWG". OGC. Retrieved 2013-10-07.
- ^ "OGC KML 2.3 Standard". OGC. 4 August 2015. Retrieved 2015-08-04.
External links
[edit]Grokipedia
Keyhole Markup Language
View on GrokipediaIntroduction
Definition and Purpose
Keyhole Markup Language (KML) is an XML-based schema designed for expressing geographic annotations and visualizations in two-dimensional maps and three-dimensional Earth browsers.[1] It originated from the EarthViewer software developed by Keyhole Inc., which was acquired by Google in 2004, leading to its integration into Google Earth.[2] KML serves as an open standard maintained by the Open Geospatial Consortium (OGC), facilitating the encoding and transport of geographic data for display in compatible applications.[1] The primary purpose of KML is to store and represent various geographic elements, including locations (points), paths (lines), polygons, images (overlays), and 3D models, enabling users to annotate and visualize spatial information effectively.[6] It supports the creation of placemarks to highlight specific sites, tours to guide users through narrated sequences of views, and network links to dynamically fetch and integrate external KML content from remote sources.[1] These capabilities make KML ideal for applications ranging from personal mapping to scientific data sharing, allowing seamless exchange of geospatial information across platforms.[1] Key features of KML include support for styling to customize the appearance of geographic elements, such as colors and icons for placemarks or line widths for paths; timestamps to associate time-based data with features, enabling animations like historical imagery or tracked movements via time sliders; and camera views to define precise observer perspectives, including orientation and altitude for immersive navigation.[1][7][4] These elements allow KML files to control not only what geographic data is displayed but also how users interact with and navigate through it in Earth browsers.[1]Development History
Keyhole, Inc. was founded in 2001 in Mountain View, California, by John Hanke and a team of engineers with backgrounds in satellite imagery and visualization software.[8] The company developed Keyhole Markup Language (KML) as an XML-based format to handle and display geospatial data within its flagship product, EarthViewer 2.0, which allowed users to interact with 3D satellite imagery and terrain models over the internet.[2] This initial implementation of KML focused on enabling placemarks, paths, and overlays to visualize locations and routes, marking the beginning of a proprietary system for geospatial annotation.[9] In October 2004, Google acquired Keyhole, Inc. for an undisclosed amount, integrating its technology into Google's ecosystem to enhance mapping capabilities.[10] The acquisition paved the way for the public release of Google Earth in June 2005, which adopted KML as its core file format for user-generated content and data interchange.[11] With this launch, KML version 2.0 was introduced, supporting expanded features such as nested folders, styles, and network links for dynamic content updates, and it underwent refinements through subsequent Google Earth releases to improve compatibility and performance.[6] Recognizing the need for broader interoperability, Google submitted KML to the Open Geospatial Consortium (OGC) in early 2007, initiating a standards development process.[12] By April 2008, KML 2.2 was approved as an official OGC standard, transitioning it from a proprietary format to an open international specification while maintaining backward compatibility.[13] In October 2015, KML 2.3 was adopted as an updated OGC standard, adding support for advanced features such as improved 3D modeling and extensions.[14] Following its standardization, KML has seen minor enhancements integrated into Google Earth updates, with ongoing support for advanced 3D modeling through features like photogrammetry-derived buildings and terrain extrusion up to version 7.3 in 2017 and beyond via web-based iterations.[15] These developments have included cloud-based integration to support collaborative mapping and AI-driven visualizations, with updates as of 2024 enabling import and storage of KML datasets in Google Earth projects via Google Drive for enhanced analysis.[16]Syntax and Structure
Core Elements and Schema
Keyhole Markup Language (KML) is structured as an XML 1.0 application, adhering to the XML schema outlined in the Open Geospatial Consortium (OGC) KML 2.3 Encoding Standard, with the core schema defined in ogckml23.xsd.[1] This schema enforces a namespace of http://www.opengis.net/kml/2.2 for standard elements (maintained for backward compatibility), ensuring interoperability in geographic data representation.[17] Google extensions, which build upon the OGC core, are defined in the additional schema kml22gx.xsd under the namespace http://www.google.com/kml/ext/2.2, but the fundamental structure remains rooted in the OGC specification.[4] The root element of any KML document is<kml>, which serves as the container for all content and must include the appropriate xmlns attribute to reference the schema.[4] Within this root, KML documents typically include <Document> elements to group related features or standalone <Placemark> elements for individual geographic annotations.[1] The <Placemark> element is the primary building block for representing spatial features, such as points of interest, paths, or areas; it can contain descriptive metadata like <name> and <description>, along with a geometry element and optional styling.[4]
Geometry in KML is specified through elements that extend the abstract <Geometry> type in the schema, including <Point> for single locations, <LineString> for linear paths composed of connected segments, and <Polygon> for enclosed areas defined by an outer boundary and optional inner boundaries (using <LinearRing>).[17] Coordinates within these geometries are provided via the <coordinates> element, which requires tuples in the order longitude, latitude [,altitude], expressed in decimal degrees for longitude (-180 to 180) and latitude (-90 to 90), with altitude in meters relative to the WGS84 datum if specified.[4] Multiple coordinate tuples are separated by spaces, and the schema mandates comma separation within each tuple without intervening spaces; altitude is optional and defaults to clamping to the ground if omitted.[1] Positioning modes are controlled by the <altitudeMode> attribute on geometry elements, supporting values such as clampToGround (default, snaps to terrain), relativeToGround (height above terrain), or absolute (height above sea level).[4]
Appearance and rendering are governed by the <Style> element, which can be defined inline within a <Placemark> or shared via <Style> within a <Document> using the <styleUrl> reference.[4] Key sub-elements of <Style> include <IconStyle> for point icons and colors (using ABGR hexadecimal values, e.g., ffff0000 for opaque blue), <LineStyle> for line width and color, and <PolyStyle> for polygon fill and outline properties.[17] The schema requires that styles conform to the <StyleSelector> type, allowing selectors like <StyleMap> for conditional rendering based on normal or highlight states.[1]
The following example illustrates a basic KML structure with a <Placemark> containing a <Point> geometry, demonstrating the schema's coordinate and element constraints:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<name>Sample Point</name>
<description>A simple geographic point.</description>
<Point>
<altitudeMode>clampToGround</altitudeMode>
<coordinates>-122.371,37.816,0</coordinates>
</Point>
</Placemark>
</kml>
This snippet validates against the ogckml23.xsd schema, with the coordinate specifying a location near San Francisco clamped to the ground surface.[4]
Document Organization
KML documents are structured as XML files with a hierarchical organization that enables the creation of complex geographic visualizations. The root element is<kml>, which encapsulates all content and declares the core namespace (xmlns="http://www.opengis.net/kml/2.2") along with optional extensions such as the Google namespace (xmlns:gx="http://www.google.com/kml/ext/2.2").[18][4] Within this root, the <Document> element serves as a primary container for organizing collections of features, styles, and schemas, allowing for shared definitions across the file.[19] <Folder> elements provide further grouping and nesting capabilities, enabling hierarchical arrangements of related features to build logical structures like categorized maps or layered data sets.[20] Additionally, <NetworkLink> elements facilitate dynamic loading by referencing remote KML files via URLs, supporting modular and updatable content without embedding everything in a single document.[21][22]
The feature hierarchy in KML builds upon this foundation, with core features like <Placemark>—which represent points, lines, or polygons—often nested within <Folder> or <Document> elements to create organized, reusable assemblies.[23] This nesting supports complex documents by allowing features to inherit styles and visibility settings from parent containers. For imagery, <GroundOverlay> elements drape raster images onto the terrain or ground plane, defined by bounding boxes, while <PhotoOverlay> elements position photos relative to the viewpoint with additional shape and rotation controls, both integrable into the hierarchy for enhanced visual layers.[24][25][26]
KML also supports interactive elements through the <Tour> feature (kml:Tour), a core element in KML 2.3 that defines guided animations and narratives. This element contains a <Playlist> that sequences actions such as <gx:FlyTo>, which smoothly transitions the view to specified coordinates over a duration, and <gx:Wait>, which introduces pauses between steps, all nested within the document hierarchy for seamless integration into broader feature sets.[27]
Files are saved with the .kml extension for plain-text XML or as .kmz for compressed ZIP archives that bundle the KML with supporting assets like images and models, preserving the hierarchical structure during distribution.[28] Namespace declarations, particularly the gx: prefix for extensions like tours, ensure compatibility while allowing proprietary enhancements without conflicting with the core OGC schema.[29]
Geodetic Reference Systems
Keyhole Markup Language (KML) employs the World Geodetic System 1984 (WGS 84) as its default coordinate reference system, specifically utilizing a 3D geocentric framework defined by the OGC URN http://www.opengis.net/def/crs/EPSG/0/4978, which corresponds to EPSG:4978 for geospatial positioning.[18] This system specifies longitude and latitude in decimal degrees, with longitude ranging from -180 to 180 degrees (positive eastward from the Prime Meridian) and latitude from -90 to 90 degrees (positive northward from the Equator).[18] Altitude is measured in meters, interpreted relative to the WGS 84 EGM96 geoid as the vertical datum, enabling accurate 3D representations of geographic features.[18] Coordinates in KML are encoded as space-separated tuples within the<coordinates> element, following the order longitude, latitude, and optional altitude (e.g., -122.207881 37.371915 156.0).[18] For geometries such as points, linestrings, and polygons, multiple tuples form arrays separated by spaces, with no commas between values within a tuple and a single space between tuples (e.g., -122.207881 37.371915 0 -122.207639 37.792136 0).[18] The <Location> element, used in features like placemarks and models, similarly structures coordinates as separate <longitude>, <latitude>, and optional <altitude> child elements, each as double-precision floating-point values.[18] Interpolation between coordinate tuples in 3D geometries, such as linestrings, occurs along straight-line segments in the WGS 84 geocentric system to maintain geometric fidelity.[18]
Altitude interpretation is controlled by the <altitudeMode> element, which supports three values: clampToGround (default, positions features on the terrain surface without elevation), relativeToGround (altitude above the ground surface, suitable for relative heights like building elevations), and absolute (altitude above the sea level geoid, for fixed elevations independent of terrain).[18] This flexibility allows KML to represent both 2D overlays and 3D volumes accurately within the WGS 84 framework.
For 3D modeling, KML includes the <extrude> boolean element in geometries like <Polygon> and <LineString>, which, when set to true, extends features vertically from their coordinates to the ground level (using clampToGround semantics), enabling visualizations such as extruded buildings or walls.[18] The <Orientation> element, applied to <Model> features, defines 3D rotations with three attributes: <heading> (azimuth in degrees, 0 north, positive clockwise), <tilt> (pitch in degrees, 0 horizontal, positive forward), and <roll> (bank in degrees, 0 level, positive clockwise), allowing precise orientation of imported 3D models relative to the WGS 84 coordinates.[18]
KML does not support alternative projections or coordinate reference systems beyond WGS 84; all geographic data must be provided in this native geographic format, with any necessary reprojection handled by the client application during rendering.[18] This design simplifies data exchange but requires consuming software, such as Earth browsers, to perform transformations for display in projected views like plate carrée.[18]
