This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

KML (.kml, .kmz)

KML map data format.
Standard GIS file format.
Stores the geometry and data of cartographic map features.
KML is an acronym for Keyhole Markup Language.
Used by Google Earth.
Consists of multiple files combined in a file archive.
XML format.
Standard format of the Open Geospatial Consortium.
  • Import imports a KML file and returns a combined rendering of all graphics layers.
  • Export exports the data to KML.
  • Import imports the specified element from a KML file.
  • Import imports multiple elements.
  • Export exports expressions representing KML features to a file.
  • See the reference pages for full general information on Import and Export.
"Elements"list of elements and options available in this file
"Rules"full list of rules for each element and option
"Options"list of rules for options, properties, and settings
  • Data representation elements:
"Data"rule-based representation for each feature of a KML archive
"Graphics"all layers combined into a single Graphics object
"GraphicsList"list of graphics representing the layers of a KML archive
"ImageOverlays"raster image overlays
  • Import by default uses the element for the KML format.
  • Import with element gives the combined graphics contents as vector and raster graphics.
  • Import returns an expression of the form . Individual layers are given as a list of rules representing the geometry as well as numerical and textual information associated with the features.
  • The element supports the following features on Export:
"ExtendedData"extended data given as lists of rules
"Geometry"list of Line, Point, and Polygon primitives
"LabeledData"data given as a list of rules
"LayerName"layer given as a string
"NetworkLinks"list of strings representing links
"Overlays"rules representing ground overlays
"PlacemarkNames"names of placemarks given as strings
  • Meta-information elements:
"LayerNames"all layer names, given as a list of strings
"LayerTypes"what graphics primitives comprise each layer
"SpatialRange"range of geographic coordinates, typically given in decimal degrees
  • Geographic coordinates in KML files always refer to the WGS84 datum.
  • General rendering options:
BackgroundNonebackground color
ImageSizeAutomaticoverall size of the image
Import all layers from a KML file:
Import layers as a list:
Import the layer names:
Import city information:
Show a list of all import elements available for this file:
Find the shortest path between the 40 largest German cities and export it to KML:
Import all layers from a KML file:
In[1]:=
Click for copyable input
Out[1]=
 
Import layers as a list:
In[1]:=
Click for copyable input
Out[1]=
 
Import the layer names:
In[1]:=
Click for copyable input
Out[1]=
 
Import city information:
In[1]:=
Click for copyable input
Out[1]=
 
Show a list of all import elements available for this file:
In[1]:=
Click for copyable input
Out[1]=
Find the shortest path between the 40 largest German cities and export it to KML:
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=