Select to view content in your preferred language

Convert Time Enabled Layer to KML using ArcPy

514
2
06-12-2023 01:50 PM
dalvon
by
Emerging Contributor

I am attempting to convert a time-enabled layer to a KML using ArcPy and have the KML be time-enabled  in Google Earth. This workflow works fine when using the regular geoprocessing tool (Layer to KML).

However, it does not work when using the arcpy.conversion.LayerToKML python function. It spits out the KML but it is not time-enabled. Has anyone experienced this? If so, do you have a solution? Thanks!

Tags (3)
0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

If the conversion tool inputs, including those related to Time Zone in the Environments tab, work from the tool, copy the python code snippet and examine it.

Arcpy just uses LayerToKML but if it is run outside Pro, then you have to specify any environments that the tool would use.

So check the code snippet if the tool in arctoolbox works

KML conversion—ArcGIS Pro | Documentation


... sort of retired...
0 Kudos
dalvon
by
Emerging Contributor

I may be looking in the wrong place, but there is no Time Zone environment in the Environments Tab of the Layer To KML Geoprocessing Tool. I examined the python snippet like you suggested, but there is no time time variable in there either. I also copied that entire code (leaving all the environments the same and only changing the input variable to match my script) into my python tool and it still did not export a time enabled KMZ. 

To provide more insight, this is my workflow for the tool:
Create layer

Add layer to the TOC

Enable Time on the layer

Export Layer to KMZ

When the python tool is done running, the layer is in the TOC and time is enabled, but the KMZ it exports is not time enabled. If I then open up the Layer to KML tool and use the output layer from my python tool as the input layer, it works fine and it produces a time enabled KMZ

0 Kudos