Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to arcgis and arcpy, so some of my lingo and terminology may be off. I have a script that takes a feature layer as an ainput. From there I want to be able to count the number of selections in the feature layer. I also want to determine what type of layer it is, i.e. polygon, polyline, point, etc. Again, my terminology may be off. Can anyone help me with this??

share|improve this question

To determine the feature type, you use describe to create a describe object of the feature layer and then use the shapeType property of the describe object. This is a modified example from that page:

import arcpy
# Create a Describe object from the feature class
desc = arcpy.Describe("C:/data/arch.dgn/Point")
# Print the shape type
print "Shape Type :   " + desc.shapeType

If you only have the feature layer, then you need to use the featureClass object of the feature layer. Another modified example, based on

import arcpy
# Create an in memory feature layer from a feature class.
# Create a Describe object from the feature layer.
desc = arcpy.Describe("mainlines_layer")
# Print the shape type
print "Feature Class Shape type: " + desc.featureClass.shapeType

To get a count of selected records, you just use the Get Count (Data Management) tool. You have to use the result object though to get the value.

count = int(arcpy.GetCount_management("Reference to layer").getOutput(0))

Get Count will return the number of selected features if there is a selection. If there is not a selection, it will return the count of all of the features in the layer.

share|improve this answer
Thanks a lot for your help. I added the suggested lines and it worked. Also gave me a better insight to arcpy and to feature layers. Thanks again! – user1898629 Mar 12 '13 at 21:36
Remember to accept the answer as correct if it is :) Glad it worked! – blord-castillo Mar 13 '13 at 13:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.