I have a client that needs individual KMZ layers exported fairly regularly. They also need the layers to have a custom symbology that needs to stay consistent. Most of the layers use unique values for their symbology. The layers are housed in an enterprise .sde. I was hoping to have everything in one .mxd and set up a script to utilize the 'map to kml' tool. Unfortunately, they won't accept a file that includes all of the layers Does anyone know of a way to accomplish this using python?
I have some experience but I'm far from expert level. Now that I've thought of this a little more, I think maybe I was overthinking. If I can set the workspace to be the .mxd and just have several 'layer to kml' lines, that should work, right?
Sort of, turn your mxd into a MapDcoument object then use ListLayers to get the layer objects in the MXD. You should then be able to pass that list layer Object into the layer to KML tool,
something like below but I've probably mistyped something
import arcpy, os mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd") df = arcpy.mapping.ListDataFrames(mxd, "") for lyr in arcpy.mapping.ListLayers(mxd, "", df): workspace = a folderpath to write kmls to outKML = create a path with something like os.path.join(workspace, lyr.name) arcpy.LayerToKML_conversion(layer, outKML)