Creating KML files

Many ArcGIS Desktop users want to share GIS data in the Keyhole Markup Language (KML) format to reach a wider audience. As a KML file can contain all the elements for data, display, descriptions, and behavior, it is a highly portable format that supports distribution requirements very well. Also, with its recent acceptance as an OGC standard, KML is quickly becoming a popular and powerful part of the GIS interoperability story.

There are three primary steps to share GIS data as a KML file:

KML files are a snapshot of the current state of the GIS data and can contain both vector and raster elements. Vector elements, in particular, are effectively shared in KML files as their geometry and symbology can be fully contained in a small file. Imagery data shared in KML files, on the other hand, must be brought across the network for display and is therefore usually defined at a limited resolution to reduce the file size. To share high-resolution imagery as KML, ArcGIS Server should be used to serve a KML network link that can send pyramid-based images across the network.

Authoring maps and layers using ArcGIS Desktop

Map layers created in ArcMap, ArcGlobe, or ArcScene are the primary mechanisms used in ArcGIS to prepare and deliver information using KML. You essentially author your map layers so that they support various KML capabilities.

KML encapsulates the graphic display of GIS features and imagery, as well as the presentation of feature attributes and other descriptive information. All this information must be authored inside ArcGIS Desktop before creating the KML file. Some of the key properties to be defined include the layer's name, the layer's label expression, and the HTML pop-up presentation of attributes.

Learn more about preparing your map documents in ArcGIS for KML publishing

Creating the KML file using geoprocessing tools

There are two geoprocessing tools available for creating KML files from ArcGIS Desktop: Layer To KML and Map To KML. These tools are available from the To KML group within the Conversion toolbox and require an ArcView license or higher. Both of the geoprocessing tools generate a KML, Zipped (KMZ) file in the specified output directory.

Layer To KML

The Layer To KML geoprocessing tool allows individual layers to be exported directly from ArcMap, ArcGlobe, or ArcScene. This is a quick and simple way to create KML data from ArcGIS Desktop.

Layer To KML geoprocessing tool

For vector layers, the layer name is used to define a folder that contains a list of all the features. Each feature's name is defined from its label expression, and its pop-up description content is populated using the HTML pop-up properties. The symbology of the layer is converted into the KML equivalent, where possible.

For raster layers, the layer name is used to define a single ground overlay element. The ground overlay displays the image draped over the surface of the globe, conforming to any underlying terrain. The layer's description property is used to populate the pop-up description for the ground overlay element.

Map To KML

The Map To KML geoprocessing tool allows multiple layers to be exported into a single KML source. The tool works on a single data frame within an ArcMap document and is an effective way of grouping many types of GIS data into a single shared unit.

Map To KML geoprocessing tool

Maps share their collection of layers as KML in one of the three following ways:

  • As a container of layers, each rendered according to separate layer rules
  • As a container of layers, each rendered as a separate KML ground overlay image
  • As a single, composite, ground overlay image representing all layers rendered together

Properties used by the geoprocessing tools

When exporting from ArcGIS Desktop, the following properties must be set:

  • The layer or map and data frame being exported
  • The name and location of the exported zipped KML file
  • The output scale (only applicable for image layers and scale-dependent rendering)

Optional parameters include these:

  • Converting of vector layers into image layers
  • Exporting a limited geographic extent
  • Setting the size and dpi of the exported images

Sharing the KML file

Once the zipped KML file has been created, it can be distributed to others in a variety of ways.

The simplest method is to simply send the file to the intended audience, for example, through a mass e-mail. Another option is to post the file to a shared network location and advise users of the download location. Both of these methods are fully supported, as the KML contains all the display elements that it requires.

However, if the KML content can be shared with the world at large, a powerful option is to post the file to a publicly available Internet location. This will allow search engines, such as Google, to catalog the content and return hits to it when users do an Internet search. This can greatly enhance the accessibility and profile of your GIS data.