版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。import sys, string, os, arcgisscripting # Create the Geoprocessor object gp = arcgisscripting.create() # Load required toolboxes... gp.AddToolbox("C:/Program Files (x86)/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx") gp.OverWriteOutput = 1 # Local variables... inputWorkspace=sys.argv[1] gp.workspace=inputWorkspace feaclasses=gp.ListFeatureClasses() fea=feaclasses.Next() i=0 while fea:	try:	gp.AddField_management(fea, "NAME", "TEXT", "", "", "", "", "NON_NULLABLE", "NON_REQUIRED", "")	fileName=os.path.split(fea)[1]	gp.CalculateField_management(fea, "NAME", "\""+fileName[0:-4] +"\"", "VB", "")	i=i+1	gp.AddMessage("第"+str(i)+"个文件:"+fea+"操作成功")	fea=feaclasses.Next()	except:	gp.AddMessage(fea+"操作失败") del fea del	feaclasses
功能:可以为一个文件夹下的所有地图分幅文件加NAME字段,并赋值该Shp文件的名字
举例:比如你有500个地图分幅文件shp格式,你想为这500个文件统一加一个name字段,并赋值地图分幅号,如果一个一个操作比较费时,这时就体现出脚本的价值了,类似工作可参考此脚本