Select to view content in your preferred language

Choosing a feature and selecting by attributes using arcpy

08-01-2018 01:54 PM
Occasional Contributor II

Hey All- Let's says I have a list of state Names in a Python script:

stateNames = ['Alabama', 'California', 'Colorado', ...]

I also have a gdb called states.gdb, that has a feature for each state: Alaska, Alabama, California, etc...

I also have an attribute value that I want to use to select certain features by attribute. Lets say its 'Fips_code' = 01007.

Using an item from my stateNames list, lets use stateNames[0] or Alabama, I want to get the Alabama feature from my states.gdb and select all of the records that have have Fips_code = 01007. Any suggestions on where to begin?

0 Kudos
1 Reply
MVP Emeritus

Select Layer By Attribute—Data Management toolbox | ArcGIS Desktop 

You can do it manually and save the expression, then use it by modifying the code snippet in the help.

In your case, query the states field for Alabama 'And' the FIP's field equal to your value