Keyhole Markup Language
KML (Keyhole Markup Language) is an OGC-standard XML format for expressing geographic features, styling, and overlays in applications like Google Earth.
Geographic data format. Conversion between geo formats requires coordinate processing.
أسئلة شائعة
How do I open and inspect a KML or KMZ file?
Google Earth Pro opens both KML and KMZ natively with full 3D rendering. For quick inspection without installing software, rename a .kmz file to .zip and extract it to access the plain-text KML inside. Any text editor can then display the XML content with coordinates and styling.
What is the difference between KML and KMZ?
KML is the raw XML file containing geographic markup. KMZ is a ZIP archive that bundles the KML with supporting files like overlay images and custom icons. KMZ files are typically much smaller because ZIP compression reduces the repetitive XML text.
Can I use KML data in web mapping libraries like Leaflet?
Yes, though Leaflet requires a plugin such as leaflet-omnivore or toGeoJSON to parse KML. These libraries convert KML geometry to GeoJSON on the client side. Complex KML features like NetworkLinks and GroundOverlays are usually not supported by web mapping plugins.
How do coordinates work in KML?
KML uses longitude,latitude,altitude order -- the reverse of the latitude-first convention common in everyday usage. Values are decimal degrees in the WGS84 datum. Altitude is optional and measured in meters, with an altitudeMode attribute controlling whether it is relative to ground, sea level, or clamped to terrain.
ما يميز .KML
Keyhole Markup Language originated at Keyhole Inc. before Google acquired it in 2004, and the Open Geospatial Consortium adopted KML 2.2 as an international standard in 2008. Google Earth's KMZ format is simply a ZIP archive containing a doc.kml file and optional overlay images -- renaming .kmz to .zip and extracting reveals the full KML source. This transparency makes KMZ a practical distribution wrapper rather than a proprietary container.
اكتشف التفاصيل التقنية
Document Structure
Every KML file has a <kml> root element bound to the namespace http://www.opengis.net/kml/2.2. Inside, a <Document> or <Folder> element organizes features hierarchically. The primary geographic primitive is <Placemark>, which pairs a geometry (point, line, polygon, or multi-geometry) with optional name, description, and styling. Coordinates appear as longitude,latitude,altitude triples with no spaces between components and spaces separating successive vertices.
Styling and Overlays
<Style> elements define icon appearance, line color and width, and polygon fill. Styles can be declared inline within a Placemark or shared via <StyleMap> with an ID reference. Ground overlays (<GroundOverlay>) drape raster images onto the terrain surface using a bounding <LatLonBox>. Screen overlays pin images to fixed viewport positions, useful for logos or legends.
NetworkLink and Live Data
The <NetworkLink> element fetches remote KML at a specified URL, enabling live-updating layers. A <refreshInterval> child controls polling frequency. This mechanism powers real-time tracking dashboards and weather layers in Google Earth. The server returns fresh KML on each request, and the client replaces the previous dataset. ViewRefreshMode allows the server to receive the current camera bounding box, generating KML tailored to the visible region — a technique Google Maps uses for dynamic feature density.
Interoperability
Google Earth and Google Maps are the primary KML consumers, but QGIS, ArcGIS, and Mapbox also import KML layers. The format handles presentation styling well, though it carries less analytical metadata than GeoJSON or Shapefile. Conversion between KML and other geospatial formats is handled by ogr2ogr from the GDAL toolkit, which preserves geometry and attributes across formats.
صيغ ذات صلة
المرجع التقني
- نوع MIME
application/vnd.google-earth.kml+xml- المطوّر
- Google (originally Keyhole Inc.)
- سنة التقديم
- 2004
- معيار مفتوح
- نعم — عرض المواصفات
البنية الثنائية
A UTF-8 XML document with a <kml> root element in the OGC namespace, containing Document or Folder elements that organize Placemarks, Styles, and Overlays in a nested hierarchy. KMZ variants are standard ZIP archives with a doc.kml entry.
نقاط الضعف
- NetworkLink elements pointing to malicious URLs that execute when a KML viewer fetches the linked resource
- XXE attacks via external entity declarations in the XML prologue if the consuming parser does not disable external entity resolution
الحماية: FileDex does not parse, render, or execute these files. Reference page only.