I'm trying to do some elementary tasks with ArcPy and ArcGIS, namely separate some information in a file into separate shapefiles based on values for a field.

My initial file has a field called "Source" and "Source" contains combined information for each record about its state and type of feature (rail, road, utlility etc.), given in a string format like "NYRDLINES" (NY, roads) or "MAUTLINES" (Massachussetts, Utilities). I want to create shapefile outputs with just information for, say, roads in NY or utilities in MA.

To do this, I've used "AddField_management" to add 2 new fields to the table: "State, and Feature type", but don't know how to retrieve the information from "Source" to separate into my 2 new fields. I think I should be using "CalculateField_management" to calculate the field values, but am stumped when it comes to defining the expression to be used.

How can I do this?

1 Answer 1


The tool that I would use to "separate some information in a [shape]file into separate shapefiles based on values for a field" is Select_analysis:

Extracts features from an input feature class or input feature layer, typically using a select or Structured Query Language (SQL) expression and stores them in an output feature class.

The same link includes some ArcPy code examples and if you have any problems with syntax for the SQL expression then there are lots of Q&As here that cover most permutations.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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