Bootstrap

arcpy批量shp批量转换为kmz

# coding=utf-8
import arcpy
import sys

reload(sys)
sys.setdefaultencoding('utf-8')

input = r""     # shp文件存放路径
output = r""    # kmz文件存放路径
arcpy.env.workspace = input
shp = arcpy.ListFeatureClasses()


for i in shp:
    arcpy.MakeFeatureLayer_management(input + "/" + i, "study_quads_lyr" + i)

    arcpy.SaveToLayerFile_management("study_quads_lyr" + i,
                                     output + "/" + i.split(".")[
                                         0] + '.lyr', "ABSOLUTE")  # 保存lyr文件

    arcpy.LayerToKML_conversion(output + "/" + i.split(".")[
        0] + '.lyr', output + "/" + i.split(".")[
                                    0] + '.kmz')     # 导出kmz文件格式
    print i

1、将要素转换为图层;

2、将图层转为为kml。

;