列出具有几何类型的地图层名称
List Map Layers names with geometry types
我正在尝试编写一个 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 layers:
循环)。
为了获得特定层的shapeType
,在循环中再次Describe
:
for lyr in layers:
desc = arcpy.Describe(lyr)
print lyr.name, desc.shapeType
我正在尝试编写一个 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 layers:
循环)。
为了获得特定层的shapeType
,在循环中再次Describe
:
for lyr in layers:
desc = arcpy.Describe(lyr)
print lyr.name, desc.shapeType