Skip to content

Instantly share code, notes, and snippets.

@jasonbot
Last active December 27, 2015 15:18
Show Gist options
  • Select an option

  • Save jasonbot/7346245 to your computer and use it in GitHub Desktop.

Select an option

Save jasonbot/7346245 to your computer and use it in GitHub Desktop.
List of layers by feature type
point_layers = []
line_layers = []
polygon_layers = []
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.isFeatureLayer:
# Try to get .shapeType attribute from data source.
# For XY event layers there is no shape type (it's a
# CSV or something) so assume it's a Point layer.
shape_type = getattr(arcpy.Describe(lyr.dataSource),
'shapeType',
'Point')
if shape_type == "Point":
point_layers.append(lyr)
elif shape_type == "Polyline":
line_layers.append(lyr)
elif shape_type == "Polygon":
polygon_layers.append(lyr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment