基本信息
源码名称:添加字段到Shape文件(通过Python给Shape文件添加字段)
源码大小:2.53KB
文件格式:.py
开发语言:Python
更新时间:2015-10-25
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 1 元×
微信扫码支付:1 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
通过Python给Shape文件添加字段,需要ArcGIS 10.0 以上版本支持
通过Python给Shape文件添加字段,需要ArcGIS 10.0 以上版本支持
import arcpy import arcpy as ARCPY import arcpy.management as DM import ErrorUtils as ERROR import SSUtilities as UTILS import SSDataObject as SSDO from arcpy import env import arcpy.cartography as CA import os #Note:This script is used to add judge fields #if this script is runned in arctoolbox, #set argis geoprocessing run in progress window to make better performace, #otherwise,set argis geoprocessing run in background. #before running this script ,you need to close other ArcGIS processes, #and close all related shapefile. #Author:luochunlin,ecitluo@163.com #InputFeature = "D:\\aaa\\test.shp" InputFeature = arcpy.GetParameterAsText(0) #OutputFolder = arcpy.GetParameterAsText(1) if not os.path.exists('d:/a'): os.makedirs('d:/a') if not os.path.exists('d:/a/a.gdb'): arcpy.CreateFileGDB_management('d:/a','a.gdb') env.workspace = "D:/a/a.gdb"; #try: # DM.DeleteField_management("export", ["area"]) #except: # print "can not delete area field area in file,ignore operation" try: DM.AddField(InputFeature, "SHENG", "TEXT","","",2) except: print "can not add field in file,ignore operation" try: DM.AddField(InputFeature, "XIAN", "TEXT","","",6) except: print "can not add field in file,ignore operation" try: DM.AddField(InputFeature, "P_NUMB", "TEXT","","",6) except: print "can not add field in file,ignore operation" try: DM.AddField(InputFeature, "XIAO_BAN", "TEXT","","",4) except: print "can not add field in file,ignore operation" try: DM.AddField(InputFeature, "MIAN_JI", "DOUBLE",18,2) except: print "can not add field in file,ignore operation" try: DM.AddField(InputFeature, "DI_LEI", "TEXT","","",3) except: print "can not add field in file,ignore operation" try: DM.AddField(InputFeature, "Y_DI_LEI", "TEXT","","",3) except: print "can not add field in file,ignore operation" try: DM.AddField(InputFeature, "BA_WO_DU", "TEXT","","",3) except: print "can not add field in file,ignore operation" try: DM.AddField(InputFeature, "H_DATE", "TEXT","","",6) except: print "can not add field in file,ignore operation" try: DM.AddField(InputFeature, "PD_PERSON", "TEXT","","",16) except: print "can not add field in file,ignore operation" try: DM.AddField(InputFeature, "REMARK", "TEXT","","",50) except: print "can not add field in file,ignore operation" DM.CalculateField(InputFeature, "MIAN_JI", "!shape.area!", "PYTHON_9.3")