我正在尝试转换10700个GPX文件,以在ArcGIS中使用。我正在尝试使用ArcGIS的arcpy包和新的gpxtofeature工具。输入是一个装满GPX文件的文件夹,输出指向一个geodatabase来保存每个新文件(我已经为这个问题更改了路径)。一旦我成功地完成了这个转换,我计划将所有的特性合并成一个巨大的特性。但是,代码中的转换工具有问题。最新的错误是“000354:名称包含无效字符”最后一个错误表示我的工具参数无效。我已经补充了arcpy.AddMessage()以查看代码是否正在读取文件以及是否能够连接新功能的名称,并成功返回第一个文件(path\name\19465409.gpx和GDB\path\name\19465409.shp)。所以我有点困惑,为什么我会收到这些错误,为什么gpxtofeature工具不能工作。你有什么想法吗? 这是我的代码:
import arcpy
from os.path import isfile, join
from arcpy import env
arcpy.env.overwriteOutput = True
gpxFolder = r'\\this\is\the\input\folder'
outputGdb = r'\\this\is\the\output\GDB\GPX2FeaturesOutput.gdb'
env.workspace =gpxFolder
def convertGPX2feature(gpxFolder, outputGdb):
for file in arcpy.ListFiles("*.gpx"):
# Convert files from .gpx to feature layer
inGPX = gpxFolder + "\\" + file
arcpy.AddMessage(inGPX)
featureName = file.partition(".gpx")[0]
outfile = outputGdb + "\\" + featureName + ".shp"
arcpy.AddMessage(outfile)
arcpy.GPXtoFeatures_conversion(inGPX,outfile)
if __name__ == "__main__":
convertGPX2feature(gpxFolder, outputGdb)
请尝试对不以数字开头的形状文件使用文件名
相关问题 更多 >
编程相关推荐