Last active
December 27, 2015 15:18
-
-
Save jasonbot/7346245 to your computer and use it in GitHub Desktop.
List of layers by feature type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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