arcpy实现kml批量转出为shp 包括shp合并

# -*- coding: utf-8 -*-
import sys
sys.path.append("D:\\Python27\\ArcGIS10.4\\python")
sys.path.append("D:\\Program Files (x86)\\ArcGIS\\Desktop10.4\\arcpy\\arcpy")
import arcpy, os

# Set workspace (where all the KMLs are) 放kml文件的文件夹,如果kml文件过多,建议50个kml一个文件夹,多执行几个py就行,否则500个kml可能要一个小时
arcpy.env.workspace = "E:\\python\\JINAN\\JINAN\\CQQ\\KMLMS"

# Set local variables and location for the consolidated file geodatabase 导出的geodata文件夹
outLocation = "E:\\python\\JINAN\\JINAN\\KMLOUT"

# Create the master FileGeodatabase

# Convert all KMZ and KML files found in the current workspace 找出kml文件,速度不快的
for kmz in arcpy.ListFiles('*.kml'):
    print("CONVERTING: " + os.path.join(arcpy.env.workspace, kmz))
    arcpy.KMLToLayer_conversion(kmz, outLocation)
# -*- coding: utf-8 -*-
import sys
sys.path.append("D:\\Python27\\ArcGIS10.4\\python")
sys.path.append("D:\\Program Files (x86)\\ArcGIS\\Desktop10.4\\arcpy\\arcpy")
import arcpy, os

# 下面是输出shp的文件夹
out_path = "E:\\python\\JINAN\\JINAN\\KML2SHP"
fcz = []
# 下面是gdb存放的的文件夹
arcpy.env.workspace = "E:\\python\\JINAN\\JINAN\\KMLOUT"

# Loop through all the FileGeodatabases within the workspace
wks = arcpy.ListWorkspaces('*', 'FileGDB')
# Skip the Master GDB
for fgdb in wks:
    # Change the workspace to the current FileGeodatabase
    arcpy.env.workspace = fgdb
    # For every Featureclass inside, copy it to the Master and use the name from the original fGDB
    featureClasses = arcpy.ListFeatureClasses('*', '', 'Placemarks')
    for fc in featureClasses:
        if fc == 'Polylines':  # 只要线段,点不要,这个看自己的需求
            print("COPYING: " + fc + " FROM: " + fgdb)
            fcCopy = fgdb + os.sep + 'Placemarks' + os.sep + fc
            print(fcCopy)
            fcz.append(fcCopy)

arcpy.Merge_management(fcz, os.path.join(out_path, 'M123.shp'))

# M123是导出shp的文件名,可以自行修改,不能重复

print("done")

在这里插入图片描述

在这里插入图片描述

python E:\python\JINAN\JINAN\kml2gdb.py

python E:\python\JINAN\JINAN\hebing.py

参考链接
https://blog.csdn.net/countsun/article/details/132254557

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值