2

Python script that checks to see if a specific layer file exists in the current workspace and, if it does, converts the layer file to a KML file. Does it work with a shapefile?

Code so far:

for file in arcpy.ListFiles("cities.shp"):
    desc = arcpy.Describe(file)
    #print "Name: " + desc.BaseName
    name = desc.baseName

    if name == "cities.shp":
         arcpy.LayerToKML_conversion("cities.shp", "cities.kmz")
         print "Converted"
    else:
        print ("There are no layers in ",env.workspace,".")
0

1 Answer 1

2

The Layer To KML tool only takes as input:

The feature or raster layer or layer file (.lyr) to be converted to KML

Consequently, you will need to use the Make Feature Layer tool first which

Creates a feature layer from an input feature class [including shapefiles] or layer file.

Not the answer you're looking for? Browse other questions tagged or ask your own question.