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!
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
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