python - 列出具有几何类型的 map 图层名称

标签 python gis arcpy

我正在尝试编写一个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/

相关文章:

Python - 在 if 语句中使用字符串作为条件

python - PySpark DataFrame - 动态加入多列

python - 如何通过 python 脚本在 ArcGIS 中添加 shapefile?

python - 不使用局部变量值 - python

python 公案 : class proxy

sql - 空间数据 SQL 重投影函数问题

c# - GPS/GIS 计算 : Algorithm to predict future position based on movement/mph?

r - 在R中的ggmap中的geom_polygon数据上绘制文本标签

python - 解决 sys.path 和 os.path.join 中的混合斜线问题

python - 在不同条件下运行一组标准的nosetests函数