Summary
In ArcGIS Pro, the Layer To KML tool exports a feature layer to Keyhole Markup Language (KML) without organizing features into folders based on field values. By default, features in the layer are placed in a single folder unless the hierarchical structure is defined before export. Creating a well-structured folder hierarchy, such as subfolders, improves usability when the KML data is viewed in ArcGIS Earth or Google Earth Pro.
The Data tab below shows the exported KML with the features organized into a single folder in ArcGIS Earth.
This article provides the workarounds to export a feature layer to KML with subfolders using field values in ArcGIS Pro.
Procedure
Create a FolderPath field and populate values using the Calculate Field tool
- In ArcGIS Pro, open the project.
- Add a new field named FolderPath with a text data type to the attribute table.
- Use the Calculate Field tool to populate values in the new field.
- Open the attribute table of the feature class, right-click the header of the new field, and click Calculate Field.
- In the Calculate Field window, for Expression Type, ensure the default Python option is selected from the drop-down menu.
- For Expression, copy the code below and paste it in the expression box. Replace <fieldName> with the original field name. In this example, the original field is ParcelStatus.
“/” + !<fieldName>!
- Click Verify
to validate the expression. - Click Apply > OK.
- Export the layer to a KML file. Refer to ArcGIS Pro: Layer To KML (Conversion) for more information.
Note:
Optionally, delete the new field or undo the field calculation after the export to prevent the Layer To KML tool from continuing to parse folders based on the field.
The Data tab below shows the field values in separate folders in ArcGIS Earth.
Use the Split By Attributes tool and group the layers
- In ArcGIS Pro, open the project.
- On the Analysis tab, in the Geoprocessing group, click Tools.
- In the Geoprocessing pane, search for and click Split By Attributes (Analysis Tools).
- Use the Split By Attributes tool to create separate layers for each unique field value. The output lists all attribute values as individual layers under the Databases folder.
- Add the layers created in Step 4 to the current map.
- In the Contents pane, create a group layer to group the layers. Refer to ArcGIS Pro: Work with group layers for instructions. In this example, the group layer is renamed polygon_test1.
- Export the layer to a KML file. Refer to ArcGIS Pro: Layer To KML (Conversion) for more information.
Note:
Features with null or blank values in the field are not exported to KML.
The Data tab below shows the field values grouped into separate folders as group layers in ArcGIS Earth.