gpt4 book ai didi

python - 如何将要素类复制到 ArcGIS/Python 中的新地理数据库中?

转载 作者:行者123 更新时间:2023-11-30 22:59:11 26 4
gpt4 key购买 nike

我尝试将要素类从文件夹复制到新的地理数据库中,但没有任何文件会复制到新的地理数据库中。他们为什么不复制?

import arcpy
from arcpy import env
env.workspace="C:\\Users\\welchk\\Desktop\\HW6_data\\data\\"
env.overwriteOutput=True

#creating the gdb
arcpy.CreateFileGDB_management("C:\\Users\\welchk\\Desktop\\HW6_data\\data\\", "t_6.gdb")

#creates a list using ListFeatureClasses function
fclist=arcpy.ListFeatureClasses("*", "polygon")

#uses CopyFeatures_management function to copy feature classes in the list to the data folder.
for fc in fclist:
#Uses the describe function so below you can tell the basename
fcdesc=arcpy.Describe(fc)
#copies the features using a function that saves the new feature class with the basename.
arcpy.CopyFeatures_management(fc, "C:\\Users\\welchk\\Desktop\\HW6_data\\data\\t_6.gdb"+fcdesc.basename)

最佳答案

"...t_6.gdb" + fcdesc.basename

您的输出文件路径缺少分隔符。

例如,如果fcdesc.basename = counties,上面的代码会尝试创建...t_6.gdbcounties(它实际上会创建一个shapefile) ...t_6.gdb\\counties(地理数据库中的要素类)。

包含结束分隔符,它会按预期运行:

"C:\\[directories]\\t_6.gdb\\" + fcdesc.basename

关于python - 如何将要素类复制到 ArcGIS/Python 中的新地理数据库中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35856031/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com