批量Append
来源:互联网 发布:马克斯cms怎么安装 编辑:程序博客网 时间:2024/06/05 22:38
GIS数据是按照图幅号组织的,现需要每个单独的系统数据进行拼接。
以下是批量追加代码:
# ---------------------------------------------------------------------------# Append.py# Created on: 2013-01-21 10:25:22.00000# (generated by ArcGIS/ModelBuilder)# Description: # ---------------------------------------------------------------------------# Import arcpy moduleimport arcpyimport os.pathimport timefrom arcpy import envSHP = "E:\\lastquick1w"dicAllFC={}fcall=[]gdbAllPath=[]#Get Dataset and FeatureClass,Store in dicAllFC,Key =ds value= fcif os.path.exists(SHP): for dirpath,dirnames,filenames in os.walk(SHP): for filename in filenames: if os.path.splitext(filename)[1]=='.mdb': mdbfilepath = os.path.join(dirpath,filename) gdbAllPath.append(mdbfilepath) env.workspace=mdbfilepath datasetlist = arcpy.ListDatasets("","Feature") for dataset in datasetlist: if isinstance(mdbfilepath,unicode): env.workspace = mdbfilepath+"\\"+dataset else: env.workspace = mdbfilepath+"\\"+dataset.decode('utf-8').encode('gb2312') fclist = arcpy.ListFeatureClasses("") if fclist and len(fclist)>0: if not dicAllFC.has_key(dataset): dicAllFC[dataset]=fclist break break#Get All MDB Pathif os.path.exists(SHP): for dirpath,dirnames,filenames in os.walk(SHP): for filename in filenames: if os.path.splitext(filename)[1]=='.mdb': if os.path.join(dirpath,filename) not in gdbAllPath: gdbAllPath.append(os.path.join(dirpath,filename))for (k,v) in dicAllFC.items(): for singlefc in v: for singlegdbPath in gdbAllPath: if isinstance(singlegdbPath,unicode): fcFullPath = singlegdbPath+"\\"+k+"\\"+singlefc else: fcFullPath = singlegdbPath+"\\"+k.decode('utf-8').encode('gb2312')+"\\"+singlefc.decode('utf-8').encode('gb2312') if arcpy.Exists(fcFullPath) and fcFullPath not in fcall: fcall.append(fcFullPath) else: print fcFullPath + " Not Exist ****************************************" if fcall and len(fcall)>=2: targetFC = fcall.pop(0) try: arcpy.Append_management(fcall,targetFC,"TEST","",""); print targetFC+"@@@succeed At "+time.strftime("%Y-%m-%d %X",time.localtime())+"###Contains "+str(len(fcall)) fcall=[] except Exception as inst: print targetFC+"@@@Failed At "+time.strftime("%Y-%m-%d %X",time.localtime())+"###Contains "+str(len(fcall)) fcall=[]print "Complete At"+time.strftime("%Y-%m-%d %X",time.localtime())
代码图片如下:
0 0
- 批量Append
- append
- append
- append
- append
- append
- 用 APPEND 批量加载数据时,可避免不合格数据
- 【优化批量插入】nologging和append使用解析
- Append Line
- 关于/*APPEND*/
- append小结
- append标签
- append 隐患
- wrap,append
- string::append
- Oracle append
- jquery append
- append.pl
- vs2010MFCActiveX控件,连接ORACLE数据库,并显示表名,字段名,并把表格在DataGrid显示
- Record Audio(录音)
- 机器学习基本算
- pentaho 5.0.1 迁移到mysql 数据库
- Linux 容器的建立和简单管理
- 批量Append
- 如何在十天内掌握线性代数
- 越狱后 第三方助手显示未越狱如何解决
- aspx前台页面取后台值
- GDI+库
- dfs.replication 详解
- 经典java读文件
- 宏和枚举及typedef
- 使List<userClass>.Contains可以查找重復的對象