Select to view content in your preferred language

Python code to check geometry type

11222
3
09-14-2011 07:50 PM
philiptivel
Emerging Contributor
I want to create an if else statement involving geometry types.

If geometry is a point run one process

elsif geometry is a line run different process.

Is there a way to do this using python?
Tags (2)
3 Replies
HenryColgate
Regular Contributor
Layer below can be full path and shapefile or a feature layer etc. 


desc = arcpy.Describe('C:/shapefile.shp')
geometryType = desc.shapeType

if geometryType == 'polygon':
    print 'Polygon'
elif geometryType == 'point'
...
philiptivel
Emerging Contributor
Worked like a charm thanks!
0 Kudos
StevenBowley1
Emerging Contributor
Worked for me , but only after changing 'polygon' to 'Polygon' and 'point' to 'Point' (uppercase P) for some reason...