I was trying to convert all the shp in a folder into kml.
featureclasses = arcpy.ListFeatureClasses()
for fc in featureclasses:
# Set Local Variables composite = 'COMPOSITE' pixels = 1024 dpi = 96 clamped = 'CLAMPED_TO_GROUND' scale = 1 outKML = fc[:-4] + ".kmz" arcpy.LayerToKML_conversion(fc,outKML, scale, composite,'', pixels, dpi, clamped)
It always says Failed to execute. Parameters are not valid. ERROR 000732: Layer: Dataset ZZZ.shp does not exist or is not supported Failed to execute (LayerToKML).
But I can manually do it within ArcMap 10.1 Desktop...
-
Welcome to GIS SE, are you defining an workspace directory before your loop?artwork21– artwork212013年09月10日 16:23:04 +00:00Commented Sep 10, 2013 at 16:23
-
Yes, I did. But I looks that is not the problemMingshu– Mingshu2013年09月10日 19:50:54 +00:00Commented Sep 10, 2013 at 19:50
1 Answer 1
This is because the Layer to KML tool takes either LAYERS (feature layers in a map for example), or LAYER FILES (.lyr files on disk pointing at featureclasses).
If you want to run this as a script outside of ArcMap you'll have to run MakeFeatureLayer on every shapefile, turning them into a layer first and pass that onto Layer to KML.
This is starter code...you'll have to modify it to make unique names. As-is it'll overwrite each KMZ it outputs.
featureclasses = arcpy.ListFeatureClasses()
for fc in featureclasses:
arcpy.MakeFeatureLayer_management(fc, "name1")
arcpy.LayerToKML_conversion("name1", r"c:\temp\foo1.kmz")
Explore related questions
See similar questions with these tags.