jnunnali

Still having problems stepping through a list inside of a tool

Discussion created by jnunnali on Apr 5, 2012
Latest reply on Apr 11, 2012 by jnunnali
I had started a thread about a month ago on this same topic but want to start again at the beginning.

I am attempting to iterate through a list inside of the SelectLayerByAttributes tool in ArcPy.  My goal is to be able to select attributes from a field (column), export the current map view with the selected attributes as a jpeg, clear the selection, and then start the process again for a different field.  I am currently trying to run all three steps within a loop.  My issue is that I can not figure out how to make the SelectLayerByAttributes tool step to the next field name after the first completes.  Currently the loop runs but just keeps selecting the values from the initial field and not changing to the next in the list.  I have attached an example of how the data is setup.


I am trying to select for values greater than zero for each column, then export the results, clear the selection, and them move to next column.


The code currently looks like this:
#Script to create distribution maps for wetland species
#Import arcpy and set workspace
import arcpy
import arcpy.mapping
arcpy.env.workspace = r"P:\CoWetlandTools\maps\distribution_maps_Johns_pytest"
import arcpy.sa
#generate a list
speciesList =("Achillea_millefolium", "Acroptilon_repens", "Actinea_osterhoutii")

#Create Loop and List to run processing for
for species in speciesList:

  #select counties each species is known to occur  
  arcpy.SelectLayerByAttribute_management ("counties_edited_datamergetest", "NEW_SELECTION", "'Achillea_milefolium' > '0'")

  #Export selected to jpeg
  mxd = arcpy.mapping.MapDocument(r"CURRENT")
  
  arcpy.mapping.ExportToJPEG(mxd, r"P:\CoWetlandTools\maps\Achillea_milefolium.jpg")

  #clear selected attributes
  arcpy.SelectLayerByAttribute_management ("counties_edited_datamergetest", "CLEAR_SELECTION")

#finished
print "Finished"


Where I need help is in the where clause of the arcpy.SelectLayerByAttribute_management function and the arcpy.mapping.ExportToJPEG function.



Any suggestions are greatly appreciated.

Attachments

Outcomes