数据是放在文件夹下的shp,现要求存在GDB中,且GDB的名字为存放shp的文件夹的名字,(如下图)
利用arcpy可以快速解决上面的需求,代码如下:
arcpy.env.workspace = u"D:/...../一级文件夹"
for dirpath, dirnames, filenames in arcpy.da.Walk(arcpy.env.workspace, datatype="FeatureClass"):
for dirname in dirnames:
arcpy.env.workspace = os.path.join(dirpath, dirname)
fcs = arcpy.ListFeatureClasses()
arcpy.CreateFileGDB_management(out_folder_path=dirpath, out_name=dirname)
arcpy.FeatureClassToGeodatabase_conversion(Input_Features= fcs, Output_Geodatabase=os.path.join(dirpath, dirname+".gdb"))