我正在尝试编写一个Python工具来显示所有图层的名称及其几何类型,但是当我运行代码时,它仅将所有图层显示为多边形。有人可以指出我哪里出错了吗?我是新手。
这是迄今为止我的代码:
import arcpy.mapping as mapping
mxd = mapping.MapDocument ("CURRENT")
layers = mapping.ListLayers(mxd)
inFC = arcpy.GetParameterAsText(0)
outFC = arcpy.GetParameterAsText(1)
desc = arcpy.Describe("C:/Program Files(x86)/ArcGIS/Desktop10.4/Reference Systems/utm.shp")
type = desc.shapeType
for lyr in layers:
print lyr.name +" " + type
最佳答案
您当前正在使用type = desc.shapeType
,描述特定shapefile的shapeType
。这不会告诉您 MXD 中的各个图层(您使用 for lyr in groups:
循环遍历这些图层)。
为了获取特定图层的shapeType
,请在循环中再次Describe
:
for lyr in layers:
desc = arcpy.Describe(lyr)
print lyr.name, desc.shapeType
关于python - 列出具有几何类型的 map 图层名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44382258/