KML conversion

Keyhole Markup Language (KML) is an XML-based format for storing geographic data and associated content and is an official Open Geospatial Consortium (OGC) standard. KML is a common format for sharing geographic data with non-GIS users as it can be easily delivered on the internet and viewed in a number of free applications. KML files have either a .kml or .kmz (for compressed or zipped KML files) file extension.

KML can be composed of point, line, polygon features, and raster imagery. KML can also contain related content such as graphics, pictures, attributes, and HTML, whereas datasets in ArcGIS are typically seen as separate and homogeneous elements (for example, point feature classes can only contain points; rasters can only contain cells or pixels and not features). A single KML file can contain features of different types as well as imagery.

Using geoprocessing tools, you can convert a map layer to KML and convert KML to an ArcGIS geodatabase, so you can view, edit, and analyze the geographic data contained in any KML file. All of the features of the KML 2.0 and 2.1 specifications are supported. None of the new features in the KML 2.2 specification are currently supported, including time animation, photo overlays, and schema tags.

KML terminology

TermDescription

KMZ

A compressed or zipped KML file. KMZ files can be viewed and worked in all the same ways as KML files.

Placemark

A point feature or location on a point, line, or polygon feature that can be clicked to display pop-up information.

Path

A line feature.

Polygon

A polygon feature.

Ground overlay

A raster or image that is typically georeferenced and draped on the earth's surface. Examples of ground overlays include aerial imagery, feature layers, or maps converted to an image.

Screen overlay

A map or screen graphic such as a logo, legend, or picture. Screen overlays are not part of the geographic display but are useful as information displays.

Tag

As KML is an XML-based format, its structure is based on various tags. For example, each point feature in a KML is inside a <Placemark> tag. The <Placemark> tag has subtags, such as <Name>, <Snippet>, and <Description>, which store information about the point as well as a <Point> subtag that stores the x-, y-, and z-coordinates.

Convert from KML

Use the KML To Layer tool to convert a .kml or .kmz file to a file geodatabase containing all features and imagery from the source KML and a layer file that maintains the colors and symbols of the source KML. In addition to the KML feature and imagery data and symbology, several other properties of the KML will also be included in the converted ArcGIS data, such as pop-up information, snippets, and other attributes. After performing this conversion, you can use the geographic data from your KML in the same ways you would any other GIS data: edit, analyze, and map it.

Convert to KML

Use the Layer To KML tool to convert any map layer to KML. KML created by this tool will be a snapshot of your data at the time the layer was converted. After creating the KML, you can share it with others who can view it in an application like Google Earth or Explorer for ArcGIS.

Before running the Layer To KML tool, you should symbolize the layer and set certain properties and modify specific data attributes. Many different aspects and properties of layers are applied to the KML during conversion, including visible attribute fields, transparency, labels, pop-up displays, and symbology. By setting layer properties and data attributes you can ensure that the KML you create matches your expectations, is easy to interpret, and is well-formed. Except where noted below, the rule of converting a layer to KML is what you see is what you get. The following table shows a number of things you can do to prepare your layers for conversion to KML.

PropertyDescription

Layer name

A layer in ArcGIS becomes a folder in the KML. The layer name will be used as the KML folder name.

KML name

Layer description

The layer description will be used as the pop-up display content for the folder.

Layer symbology

The layer symbology will be used as the KML symbol. For feature layers, not all ArcGIS symbols are supported in KML. Consider this general rule: only simple symbols are supported.

For line features, only simple symbols with basic color and line width properties are supported; advanced effects such as dashes and arrows and multilevel or layered symbols are not supported.

Point features will export the current symbol and use a .png to display the symbol. 3D symbols and other complex identifiers are not supported.

For polygon features, only simple color fills with simple line borders are supported; no patterned, hatching, or gradient fills are supported, and the same rules for lines apply to polygon borders. If you require more than simple symbols for your features, use the Return single composite image parameter of the Layer To KML tool to convert the symbolized features into a raster image that maintains complex symbology.

Feature name

If labels are turned on, the layer's label field or expression will be used for the feature name in the KML. If labels are not turned on, the layer's display field or expression will be used for the name. If neither of these layer properties are set, values from a field named Name will be used for the name.

Feature label

If layer labels are turned on, the layer label field or expression will be used to name each KML feature and labels will be turned on.

Note:

Only point features will be labeled. For line of polygon features, centroids can be created and labeled to achieve a label effect.

Feature snippet

The snippet of a feature can be set by changing the alias of any existing field to KMLSnippet. Alternatively, values in the feature layer's Snippet field will be used as the snippet of each feature in the KML.

Feature pop-up display

By default, the pop-up display will be composed of all visible fields from the layer. KML feature pop-up displays can also be set using the layer's customized pop-ups. If the layer pop-ups have not been customized, the values in the feature layer's PopupInfo field will be shown in the pop-up display when a KML feature is clicked. These values can be numeric or text attributes as well as HTML-formatted code stored in a text field.

Folders and subfolders

You can assign a folder structure to the layers and features in your KML. If the layer has a field named FolderPath, the values in that field will be used for defining the KML folders and subfolders. Within that field the path separator between folders and subfolders must be a forward slash ( / ). If the layer does not have a FolderPath field, you can define a folder and subfolder structure by using group layers. Specify the group layer itself as the input to the Layer To KML tool to get the group layer structure in the KML.

3D Feature elevation

KML will be created in 3D if the feature layer is z-enabled and has z-values in the geometry. Also, when a layer has 3D display effects applied, such base height or extrusion, those 3D effects will be maintained in the output KML. If none of these layer effects are applied, field attributes are used to control 3D effects. For a detailed explanation, see the following section on 3D creation.

Create 3D KML

The following field attributes (all of type integer) are used to control the placement and properties of features in the 3D space (on top of or floating on a surface).

Caution:

KML uses the WGS84 coordinate system and meters for the unit of measurement. All elevation values are assumed to be in meters when creating KML.

Layer properties for 3D conversion

FieldValueExplanation

AltMode

0 or -1

A value of 0 sets the height to the KML setting of absolute and should be used when your features are z-enabled. A value of -1 places your features relative to the surface of the earth.

Base

Any numerical value

Any numerical value can be used. When this value is used with a relative placement (AltMode=-1), the value controls the height of the features above the earth's surface.

Caution:

If your features have a z-value of 100 and are in a geographical area where the earth's surface is higher then 100, an absolute setting will cause your features to be placed under the surface of the earth.

Extruded

0 or -1

A value of 0 sets no extrusion, while -1 creates an extrusion effect. Extrusion of features makes polygons look like blocks with their sides continuing down from the polygon into the earth's surface.

The green polygons on the left (OID 3 and 4) of the following image are features without elevation, or z-values, while the red and gray features on the right have elevation values. Similar effects can be applied to features with and without z-values. For example, the green extruded polygon (OID 3) has no z-values and the following fields set: AltMode = -1, Base = 25, and Extruded = -1. The extruded red polygon (OID 2) has a z-value of 1300 and the following fields: AltMode = 0, Base = 0, and Extruded = -1. Because the red feature (OID 2) has an elevation value, its position is set to absolute, and only extrusion is used.

Controlling 3D behaviors
Note:

The optional parameter on the Layer To KML tool, Clamped features to ground, will override 3D settings and all your features will be draped on the earth's surface. This parameter is useful when creating KML from features with z-values below the earth's surface or 3D effects are not required. Alternatively, using a field named Clamped with a setting of -1 will produce the same effects as using the optional parameter on a per-feature basis.