1

I'm trying to export massive shp to kmz aplying simbology.

The code without transparency works good:

    import arcpy, os  
    workspace = r'C:\\folder\\of\\the\\workspace\\'  
    in_symbology_layer = 'lyr.lyr'
    arcpy.env.workspace = workspace  
    for dirpath, dirnames, filenames in arcpy.da.Walk(workspace, datatype = "FeatureClass", type = "Polygon"):  
        for filename in filenames:  
            lyrname = os.path.splitext(filename)[0]
            arcpy.MakeFeatureLayer_management(filename, lyrname)
            arcpy.ApplySymbologyFromLayer_management (lyrname, in_symbology_layer)
            arcpy.LayerToKML_conversion(lyrname, lyrname + '.kmz')

When I try to export it with the transparency it doesn't work:

    import arcpy, os  
    workspace = r'C:\\folder\\of\\the\\workspace\\'  
    in_symbology_layer = 'lyr.lyr'
    arcpy.env.workspace = workspace  
    for dirpath, dirnames, filenames in arcpy.da.Walk(workspace, datatype = "FeatureClass", type = "Polygon"):  
        for filename in filenames:  
            lyrname = os.path.splitext(filename)[0]
            arcpy.MakeFeatureLayer_management(filename, lyrname)

            lyrname = arcpy.mapping.Layer(in_symbology_layer)               
            lyrname.transparency = 50 

            arcpy.ApplySymbologyFromLayer_management (lyrname, in_symbology_layer)
            arcpy.LayerToKML_conversion(lyrname, lyrname + '.kmz')

Do you know how to resolve this problem?

1

try with this:

import arcpy, os  
workspace = r'path' 
symbologyLayer = 'lyr.lyr' 
arcpy.env.workspace = workspace  
for dirpath, dirnames, filenames in arcpy.da.Walk(workspace, datatype = 
"FeatureClass", type = "Polygon"):  
for filename in filenames:  
     lyrname = os.path.splitext(filename)[0]  
     arcpy.MakeFeatureLayer_management(filename, lyrname)
     arcpy.ApplySymbologyFromLayer_management(lyrname, symbologyLayer)
     yourLayer = arcpy.mapping.Layer(lyrname) 
     yourLayer.transparency = 50 #as a percentage
     arcpy.LayerToKML_conversion(lyrname, lyrname + '.shp.kmz')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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