Creating KML in ArcGIS Desktop is an easy process involving three primary steps:
- Author layers and maps in one of the ArcGIS Desktop applications (ArcMap, ArcGlobe, and ArcScene).
- Prepare the layers and maps to be converted to KML by setting certain properties and data attributes that will ensure the KML created matches your requirements and is user-friendly and well-formed.
- Create the KML file using one of the KML conversion tools: Layer To KML or Map To KML. You can also create KML from your 3D multipatch feature classes using the Multipatch To COLLADA tool.
Author layers and maps
Both feature and raster layers and ArcMap map documents (.mxd) can be converted to KML. Before they can be converted to KML, feature classes or raster datasets must first be added to the display (automatically makes a layer from the dataset) or made into a layer using the Make Feature Layer or Make Raster Layer tools.
KML created in ArcGIS Desktop represents a snapshot of the layers and maps at the time they were converted to KML. How your layers look in ArcGIS Desktop will for the most part match how they will look as KML; for example, if you want the KML to have a certain symbol or color, work in ArcMap to give the map layer the desired symbology and export it to KML.
Preparing layers and maps to be converted to KML
Many different aspects and properties of layers authored in ArcGIS Desktop 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 requirements and is user-friendly and well-formed. Except where noted below, the rule of converting a layer or map 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.
Layer properties and KML conversion
A feature layer in ArcGIS becomes a folder in the KML. The layer name will be used as the KML folder name.
The layer description will be used as the pop-up display content for the folder.
The layer symbology will be used as the KML symbol.
For feature layers, not all ArcGIS symbols are supported in KML. 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. 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 or Map To KML tools to convert the symbolized features into a raster image that maintains complex symbology.
If feature labels are turned on, the layer's label field or expression will be used for the name. 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.
When 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.
The snippet of a feature can be set by changing the alias of an 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 HTML pop-up properties. If the layer HTML pop-up displays are turned off, 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
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 first character should be a forward slash ( / ), as should the path separator between folders and subfolders. 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.
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 in ArcGlobe or ArcScene (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.
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).
Layer properties for 3D conversion
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.
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.
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 in the back left of the following screen capture are features without elevation, or Z-values, while the red and gray features in the front right have elevation values. Similar effects can be applied to features with and without z-values. For example, the green extruded polygon has no z-values and the following fields set: AltMode = -1, Base = 25, and Extruded= -1. The extruded red polygon has a z-value of 1,300 and the following fields: AltMode = 0, Base = 0, and Extruded = -1. Because the red feature has an elevation value, its position is set to absolute and only extrusion is used.
There are also map properties that you can use to control how map documents converted to KML will look and behave. The following table shows a number of things you can do to prepare your maps for conversion to KML.
Map properties and KML conversion
Map data frame name
Only a single data frame can be exported to KML at a time. The map data frame name will be used as the top name in the KML.
Map data frame description
The data frame description will be used as the pop-up display content for the top KML item.
A legend is the only screen overlay that you can include in your KML created in ArcGIS Desktop. Legends added in the map document layout view will be included as a KML screen overlay and a button folder that allows you to change where the legend will be displayed on the screen. Legend overlays will only be included in the KML when using the Map To KML tool.
Create the KML file
There are two geoprocessing tools available for creating KML files from ArcGIS data: Layer To KML and Map To KML. Both tools create a KMZ (compressed KML) file in the output location. Additionally, the Multipatch To COLLADA tool creates a related KML file when converting from a multipatch feature class to COLLADA files.
Layer To KML
The Layer To KML tool allows individual layers to be exported directly from ArcMap, ArcGlobe, or ArcScene.
Map To KML
The Map To KML tool allows multiple layers in an ArcMap map document data frame to be simultaneously exported to a KML file. Each layer will be maintained as a distinct folder in the KML, unless the option is used to convert all layers to a single flattened image.
Multipatch To COLLADA
The Multipatch To COLLADA tool can be used to export multipatches to COLLADA files on disk. COLLADA is a 3D model format that is supported in many 3D applications, including Google Earth. If the multipatch feature class you are converting is in a projected coordinate system, the tool will create a KML file in the output folder, which will assign geographic coordinates to the 3D models in the COLLADA files.