【问题标题】:List Map Layers names with geometry types列出具有几何类型的地图图层名称
【发布时间】:2017-06-06 05:52:35
【问题描述】:

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

【问题讨论】:

标签: python gis arcpy


【解决方案1】:

您当前正在使用 type = desc.shapeType,描述特定 shapefile 的 shapeType。这不会告诉您 MXD 中的各个层(您正在循环使用 for lyr in layers:)。

为了获得特定层的shapeType,在循环内再次Describe

for lyr in layers:
    desc = arcpy.Describe(lyr)
    print lyr.name, desc.shapeType

【讨论】:

  • 乐于助人! :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-04-26
  • 2016-01-12
  • 2014-06-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多