Select to view content in your preferred language

Layer to KML 'Name' missing when using python

2606
11
07-08-2018 07:41 PM
MarkHansen1
New Contributor II

Hi,

I'm exporting a point features to kml via a python script but the generated kml has no 'Name'  information.  i.e. when you expand the list, every point says "[no name]".  All other data is correct.

There is a 'Name' field in the attribute table.  It is the first field after the Object ID and geometry field.

simplified code:

arcpy.management.MakeFeatureLayer(InFc, OutLyr, None, None, None)
OutKmzPath = ProjectPath + "out.kmz"
arcpy.conversion.LayerToKML(OutLyr, OutKmzPath, 0, "NO_COMPOSITE", "DEFAULT", 1024, 96, "ABSOLUTE")

but, if i do the same from within ArcGIS Pro (v2.2) the generated kml has the name field correctly populated. 

Is there another step to get the kml Name field to populate when running in a script?

0 Kudos
11 Replies
MarkHansen1
New Contributor II

Thanks Dan,

The 'save to layer file' alone didn't work but it got me thinking - so I created a single point and labeled/styled it and saved a lyrx file, then used  arcpy.management.ApplySymbologyFromLayer using my saved lyrx file and it worked.

0 Kudos
DanPatterson_Retired
MVP Emeritus

So... some mystery lurks between the within-Pro and without-Pro functionality.

0 Kudos