Preparing your map documents in ArcGIS for KML publishing
ArcGIS supports publishing of GIS data as KML in two ways—as a KML file or as a KML service (network link). In both cases, the presentation of the data must be defined using ArcGIS Desktop before the KML representation can be created. KML files can be created from an individual layer or from a map, while KML services can only be created from maps.
The goal of this topic is to provide an overview of the ArcGIS elements and properties that need to be defined to create an effective KML presentation of GIS data.
Preparing ArcGIS elements for KML publishing
The main elements to be authored when sharing GIS data as KML are
- Layers: Required for creating KML files or KML services
- Maps: Required for creating KML services and optional for creating KML files
- Legends: Optional for creating KML files and KML services
Layers are the primary component of sharing GIS data as KML. Layers define the symbology of the data, the displayed name of the layer and features, and the descriptive content shown in the pop-up balloon. Layers can be defined in ArcMap, ArcGlobe, or ArcScene. Feature layers, image layers, and group layers can all be published as KML.
Feature layers create a KML folder containing a list of all the features. The key KML settings of a feature layer are
- The Layer Name property, which is used as the folder name
- The Layer Description property, which is used as the pop-up content for the containing folder
- The Symbology, which is used to create a KML symbol
- See the Display properties section below for more information on KML symbols.
- The Label expression, which is used to name each feature
- The Definition Query, which can be used to limit which features are included in the KML representation
- The HTML Popup properties, which are used to define the pop-up content for individual features
- See the Displaying feature attributes section below for more information.
Image layers create a single ground overlay element, referencing an image file. The image file is recommended to be as small as possible, as it must be transmitted across the network to the client application. The key KML settings of an image layer are
- The Layer Name property, which is used as the ground overlay name
- The Layer Description property, which is used as the pop-up content for the ground overlay
Group layers work as organizational folders that can contain other organizational folders, feature folders, and ground overlays. The key KML settings of a group layer are
- The Layer Name property, which is used as the folder name
- The Layer Description property, which is used as the pop-up content for the folder
Layers can be exported to KML files directly from ArcMap, ArcGlobe, or ArcScene using the Layer To KML geoprocessing tool. Layers can only be served as a KML service as part of a map document that is published using ArcGIS Server.
Maps allow sharing of multiple layers as a single KML source. They are also required for creating a KML service. Only one data frame per map can be exported or served as KML at a time.
Maps define the topmost folder for the KML and the pop-up balloon descriptive content for that folder. Maps must be defined in ArcMap. The key KML settings of a map are
- The Data Frame Name property, which is used as the folder name
- The Map Description property, which is used as the pop-up content for the folder
- The visibility of layers, which is used to set which layers will be included in the KML
Layers that have their visibility disabled due to their scale visibility range are also excluded when the map is converted into KML.
Legends are an optional inclusion to the KML representation of a map. An image of the legend is displayed as a KML screen overlay within the viewing application. It is presented in a button folder that allows the user to interactively set where on the screen the image is displayed, for example, in the upper left corner.
Legends must be created on the Layout view of a map document and can include any subset of the layers within the map document. The symbology of the legend should be done in the same manner as authoring any legend.
If a map document is exported or served as KML, any Legend element in the map is automatically included in the KML.
Displaying feature attributes
Feature attributes for GIS data are stored in a set of database fields. Each column is of a defined type, such as Date or Text, and every feature has a value, or null, for that column.
KML descriptive information, on the other hand, is stored in a single HTML-formatted text block. Every feature can have totally unique content when compared to other features.
ArcGIS uses layer properties to support the definition of how the regularly defined GIS feature attributes are displayed in the HTML representation of feature descriptions in KML.
The key KML settings for sharing feature attributes are
- The HTML Popup configuration, which is used to populate the HTML definition of a feature's description
- The three options available are
- As a table of visible fields, which is the default option and best for HTML content embedded inside geodatabase fields
- As a URL, which is best for pointing features at a set of predefined HTML pages
- As a formatted page based on an XSL template, which is best for advanced formatting
- The three options available are
- The Layer Visible fields, which are used for the As a table of visible fields option.
Setting layer symbology
There are two components for setting the display of a layer in ArcGIS Desktop—the renderer and the symbology. A layer's renderer defines the classifications, and the symbology defines how each classification should be displayed. For example, a unique value renderer for a land-use polygon layer defines classifications for Agricultural, Commercial, Industrial, Recreation, and Residential regions. Each of these classifications then has a symbol associated with it, allowing, for example, Agricultural features to be displayed as green polygons.
Using renderers that work in KML
Each feature displayed in KML can define its own symbology. It can contain the entire symbology within itself, or it can reference a style map. In either case, this allows each KML feature to have any symbol. When features are exported or served as KML from ArcGIS, the renderer is queried, and the corresponding symbol is assigned to the KML element.
This means that any renderer can be used to set the layer symbology for KML.
Using feature symbology that works in KML
KML feature symbology is a subset of ArcGIS symbology, so some symbols may not translate into KML. The simplest rule to follow when preparing layers for KML is to keep the symbology as simple as possible. However, point, line, and polygon symbology are handled differently in KML and can be pushed to different limits.
KML point symbols are displayed as billboarded images. When the KML is authored through ArcGIS Desktop, the ArcGIS symbol is converted into a PNG image and billboarded to always face the camera as the user navigates through the 3D view. This means that even very complex point symbols can be used in KML, as their 2D representation is simply converted into an image.
For line features, however, only simple symbols are supported in KML. Color and line width properties are honored, but additional effects, such as dashes and arrows, are not. Also, multilevel symbols, such as the Railroad symbol, are not supported in KML. When authoring line features to be displayed in KML, symbols should be kept as simple as possible.
Similarly, KML polygon features only support simple symbology. KML polygon symbols must be simple color fills, with no patterned fills or hatching supported. The line symbol for polygon perimeters follow the same rules as KML line symbols. When authoring polygon features to be displayed in KML, symbols should be kept as simple as possible.
Displaying the map or layer as an image
An option when sharing a map or layer as KML is to display the content as an image. This technique is particularly effective for feature layers that need to be draped over the surface of the globe. When displaying feature content in this way, the ArcGIS symbology is embedded in the image exported into the KML. Any image layers, whether they are native image layers or feature layers being converted to images, will support the full suite of ArcGIS symbology when displayed as KML.
To effectively use this option, the KML content should be served as a network link through ArcGIS Server, so the displayed image can be displayed at an applicable resolution as the user zooms in and out of the view. A stand-alone KML file displaying image content will have a snapshot of the content, which is applicable only to the scale at which it was created—zooming in shows coarse data, and zooming out shows a limited extent.
Setting 3D display properties
The primary display environment for KML is in 3D. There are several 3D display properties that can be authored in ArcGlobe and ArcScene that can enhance the appearance of the GIS data when shared as KML.
The key 3D display properties that can be authored from ArcGlobe and ArcScene are
- Extrusion, which displays points as vertical lines, lines as vertical walls, and polygons as 3D blocks
- 3D base heights of features, which allows features to be lifted from the surface based on attributes
- 3D geometries, which can natively place z-aware points, lines, polygons, and multipatches in 3D
Some 3D display properties, such as the use of textured models as symbols, are not currently supported in the export to KML geoprocessing tools. For example, a point feature class that uses the Aston Martin automobile symbol will not be displayed as KML. Also, textures on multipatches, such as textured building models, will not be included in the exported or served KML. Both of these techniques require the GIS data to be exported into COLLADA format, which can be done as an alternate process using the Multipatch To COLLADA geoprocessing tool.