Can someone please throw me a code sample to iterate through features in a Shapefile and export each as a KMZ?
I've been able go through a list of Shapefiles in a Data Frame and convert those to KMZs but cant get the syntax right to go through the individual features of a Shapefile and convert those to KMZs.
Thank you!
Solved! Go to Solution.
ahhh you want a search cursor (see code examples) to get the shapes prior to making them a temporary layer, then out to kml
so this is the tool you are using Layer To KML—Help | ArcGIS for Desktop currently?
What code do you have since you will need to create a layer file for each feature or convert the kmz to kmls... can't remember but this is in my bookmarks
I wasn't able to find a way to list the features in the Shapefile like you can list the Shapefiles in the Data Frame.
Taking the important parts from a larger script:
import arcpy
from arcpy import env
import os
activeoutputfolder= "C:\\Users"
mxd=arcpy.mapping.MapDocument("CURRENT") # The active Arcmap file
df= arcpy.mapping.ListDataFrames(mxd,"")[0] # "Layers"
lyr=arcpy.mapping.ListLayers(mxd,"",df)[0] # first thing in "Layers"
#------kmz export part
for x in range (0,3):
namea= arcpy.mapping.ListLayers(mxd,"",df)
outputfile= str(activeoutputfolder)+"\\"+str(namea)+".kmz"
inputa= arcpy.mapping.ListLayers(mxd,"",df)
arcpy.LayerToKML_conversion(str(inputa), str(outputfile), "0", "false", "DEFAULT", "1024", "96", "CLAMPED_TO_GROUND")
ahhh you want a search cursor (see code examples) to get the shapes prior to making them a temporary layer, then out to kml
Please check my software Lidar viewer 1.0 free version . it will convert POI into kml file. After providing correct geodetic information.
LINK-- LidarViewer
Ravendra....getting a 403 error when trying to download.
hello Rebecca,
in my computer it is easily downloadable. please try again on this link.
http://docs.google.com/uc?export=download&id=0B8sX5C0TZa-GeEJiSHY0TWZUUW8
hope it is working.
not for me, but maybe it's blocked on my network
hello ,
sorry its my fault . it did not activate the link in google drive. now link is ok.
http://docs.google.com/uc?export=download&id=0B8sX5C0TZa-GeEJiSHY0TWZUUW8
please try it. and thanks for downloading.
download worked now.