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'm using arcmap 10.1 and have one shp with many polygons with different typeID. I want to make a serie of maps showing each typeID on an individual map. Since I have many typeIDs I want to use arcpy. And here is the problem. I don't know which arcpy function to use to select only one typeID and remove all the others; and then repeat this step for all IDs.

SOLUTION: Here is my code after I fixed it. Now it works:)


def getValueList (inputTable, field):
    values = set()
    rows = arcpy.SearchCursor(inputTable)
    for row in rows:
    return sorted(values)

list=getValueList('my_shp_file', 'typeID')

for type in list:
    arcpy.mapping.ExportToJPEG(mxd, "C:\\my_location\\"+str(type)+".jpg")

Thanks for suggestions! Rok

share|improve this question
If you have a layer file in your mxd pointing to your shapefile you can get to it's definition query and set it to be typeID="value" and then save. I'm not sure how set() works but you'll probably want to ensure your list is unique.… – Justin Oct 28 '12 at 20:16
up vote 2 down vote accepted

Just use Layer object do something like:

where_clause = "'" + my_field + " = " + typeID + "'"
if yourLayer.supports("DEFINITIONQUERY"):
    yourLayer.definitionQuery = where_clause

It works great!

share|improve this answer

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.