ArcMap按字段内容分类导出图形
背景描述:
实际项目中,需要对一个图层中的某个字段,分类型输出为单独的新图层。FME提供了Fanout工具。在没有FME的环境下,借助ArcGIS Desktop自带的python模块Arcpy,同样实现类似效果。
import arcpy
from arcpy import env
#设置工作空间
env.workspace = "D:/cad/newbuilding/NewBuilding.mdb/dataset"
#调用toolbox,CopyFeatures
arcpy.CopyFeatures_management("Floor7","Floor7Copy")
<Result 'D:/cad/newbuilding/NewBuilding.mdb/dataset\\Floor7Copy'>
#打印图层字段名称
floorFields = arcpy.ListFields("Floor7")
for filed in floorFields:
print field.name
#输出字段唯一值
values = [row[0] for row in arcpy.da.SearchCursor("Floor7",("Layer"))]
uniqueValues = set(values)
for v in uniqueValues:
print v
#按唯一值输出图层
i = 0
for v in uniqueValues:
wc = "Layer = '%s'"%v
arcpy.MakeFeatureLayer_management("Floor7","LayerCopy%s_lyr"%i,wc)
arcpy.CopyFeatures_management("LayerCopy%s_lyr"%i, "%s-%s"%(i,v))
arcpy.Delete_management("LayerCopy%s_lyr"%i)
i = i + 1
print v
转载自:https://blog.csdn.net/dcj_gis2006/article/details/41007453