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

First to describe my problem as I see it. I've been asked to design a tool that will take a selected features attributes and copy it out to an output table, with each successive selection and processing of the tool adding a new row to the formerly mentioned output table. I'm trying to work exclusively in Python since my VB knowledge is None (or perhaps Null?).
My current method has been to make a Layer View consisting only of the feature that the user has selected and then use a search cursor to snatch the data and populate the other table with use of an insert cursor. This seems clearly inefficient to me, but more appropriate methods have not made themselves clear to me. However, to make matters worse, it would seem that my Layer View is simply creating a copy of the original table because I don't have a method for singling out a unique identifying attribute to create a Layer View with 1 feature.

A couple of questions, then.

1) Is it possible through python/arcpy to access the attributes of a currently selected feature?
2) If this is not possible, what are other methods that come to mind for performing the task of extracting data from one feature class and using it to populate fields in a separate table?

share|improve this question
This highlights the paucity of record-level data access tools provided with arcpy, in contrast, for example, the ease with which you can navigate through data tables with VB / MS Access. In engineering-related GIS work, it is often necessary to access and modify data at the individual row level, as is commonly done in non-spatial databases. Feature layers and the insert, search and update cursors comprise a basic and clunky toolset to do this. – user13366 Dec 6 '12 at 5:29
up vote 9 down vote accepted

All tools and methods in Python use the selected set if there is one or if there is no selection it uses the whole feature class.

You must be making sure that your input to the script is of Feature Layer type when setting the script up in the toolbox not Feature Class. Then for the input of cursors and tools you input the parameter Feature Layer from which the user has selected in the drop down.

More information on cursors can be found here:

share|improve this answer
You got it. Turns out I was somehow messing up the view creation in my call to the tool. The cursors are working as intended. Thanks. – Nathanus Mar 16 '11 at 16:25

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.