Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 have a question regarding selections in ArcGIS for Desktop. Assumed I have one layer in ArcMap and I have selected two of five features. Is it possible to get a list of all selected features by using Python? It would be fine if there is a way to get one special (or all) attribute(s) of the selected features stored in a list that can be written into a txt file.

Is it possible to do this in ArcGIS for Desktop?

share|improve this question
up vote 24 down vote accepted

Any time you have a selection on a layer a cursor object will only return the selected rows.

for row in arcpy.SearchCursor("name_of_layer_with_selection"):
    print row.field1, row.field2
share|improve this answer
But the problem though is that if you get all the features returned you don't know if ALL or NONE were selected. – Matej Apr 21 '14 at 14:01
Does this also apply to selected features in feature class ? – Larry Sep 4 '15 at 18:22

the Describe function will also return a list. I am not sure if this is faster than the cursor method but I have fond this to be a useful tool. The resulting list is the object id's for the selection set.

import arcpy

aa = arcpy.Describe("someFC")
ss = aa.FIDset
tt = ss.split("; ")
Print tt

[u'1363', u'1364', u'1365', u'1367', u'1369', u'1370']
share|improve this answer
Good solution too! Sadly I am not able to set two times the green heel. This solution makes the script also independent from different ArcGIS Versions, because in ArcGIS 10.1 the cursors are called in a different way than in ArcGIs 10.0 (ArcGIS 10.1 arcpy.da.SearchCursor, ArcGIS 10.0 arcpy.SearchCursor...). – Sven Dec 31 '12 at 20:38
Both cursor types are available at 10.1. You don't have to use the new arcpy.da cursors. – blah238 Dec 31 '12 at 20:53
Ah, ok. Thanks. – Sven Dec 31 '12 at 20:58

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.