Kml to Layer in Script Gives No Result

192
1
11-11-2019 04:14 PM
TracyLiu
New Contributor

Hi,

I am trying to build a tool that converts a layer to a kmz at the end. I tested the following code in my IDE and it works fine. But once I add the exact same lines as a script to ArcPro and run it from there it produces nothing. I have tried this on different layers (group/single) and all with the same result so I don't think it's specific to my layer. 

I'm wondering why this happens. Workarounds are fine too as long as I can get the script to run in ArcPro. 

KmzOutput= r"C:\Users\tracy\OneDrive\Documents\Python Scripts\Sample.kmz"
LayerFile= r"E:\\GIS_DoNotSynch\\ArcpyToolFiles\\Scratch\\Sample.lyrx"
arcpy.LayerToKML_conversion(LayerFile,KmzOutput)

Thank you!

Tags (2)
0 Kudos
1 Reply
AdamEversole1
Esri Contributor

Hi Tracy, 

My name is Adam I work in Esri support, Thank you for the post, we are investigating this tools on support case. 

Did you try a layer instead of a layer file? 

import arcpy

in_feature = r'C:\GIS\My_Data.shp'
out_kml = r'C:\GIS\my_KMZ_test.kmz'

arcpy.MakeFeatureLayer_management(in_feature, "Map_Layer")
arcpy.LayerToKML_conversion("Map_Layer", out_kml) 

Let me know if this works or not, 

-Adam

Esri Support Services.

0 Kudos