kml文件转成cvs_KML 转图层 (转换)

KMLToLayer 示例 2(独立脚本)

以下脚本会将 KMZ 和 KML 文件的文件夹转换为其各自的文件地理数据库。然后,会将这些文件地理数据库内的要素类合并到单个文件地理数据库中。

注:此脚本不维护 KMLToLayer 工具中的图层文件。

# Name: BatchKML_to_GDB.py

# Description: Converts a directory of KMLs and copies the output into a single

# fGDB. A 2 step process: first convert the KML files, and then

# copy the feature classes.

# Import system modules

import arcpy

import os

# Set workspace (where all the KMLs are)

arcpy.env.workspace = "C:/VancouverData/KML"

# Set local variables and location for the consolidated file geodatabase

out_location = "C:/WorkingData/fGDBs"

gdb = 'AllKMLLayers.gdb'

gdb_location = os.path.join(out_location, gdb)

# Create the master FileGeodatabase

arcpy.CreateFileGDB_management(out_location, gdb)

# Convert all KMZ and KML files found in the current workspace

for kmz in arcpy.ListFiles('*.KM*'):

print("CONVERTING: {0}".format(os.path.join(arcpy.env.workspace, kmz)))

arcpy.KMLToLayer_conversion(kmz, out_location)

# Change the workspace to fGDB location

arcpy.env.workspace = out_location

# Loop through all the FileGeodatabases within the workspace

wks = arcpy.ListWorkspaces('*', 'FileGDB')

# Skip the Master GDB

wks.remove(gdb_location)

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

feature_classes = arcpy.ListFeatureClasses('*', '', 'Placemarks')

for fc in feature_classes:

print("COPYING: {} FROM: {}".format(fc, fgdb))

fcCopy = os.path.join(fgdb, 'Placemarks', fc)

arcpy.FeatureClassToFeatureClass_conversion(

fcCopy, gdb_location, fgdb[fgdb.rfind(os.sep) + 1:-4])

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值