#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"arcpy.SelectLayerByAttribute_management("counties_edited_datamergetest", "NEW_SELECTION", "'" + str(species) + "' > 0 " )
#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.mxd"
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:
print species
#select counties each species is known to occur
arcpy.SelectLayerByAttribute_management ("counties_edited_datamergetest", "NEW_SELECTION", '"' + str(species) + '" > 0')
#Export selected to jpeg
mxd = arcpy.mapping.MapDocument(r"CURRENT")
arcpy.mapping.ExportToJPEG(mxd, r"P:\CoWetlandTools\maps\"'" + str(species) + "'.jpg")
#clear selected attributes
arcpy.SelectLayerByAttribute_management ("counties_edited_datamergetest", "CLEAR_SELECTION")
#finished
print "Finished"
arcpy.SelectLayerByAttribute_management ("counties_edited_datamergetest", "NEW_SELECTION", "\"%s\" > 0" % species)
#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.mxd"
import arcpy.sa
#list object that is the list of fields in our table
#List fields and generate a list
fields = arcpy.ListFields(r"Y:\John_N\Wetland_field_guide_distribution_maps\counties_edited_datamergetest_export.shp", None , "Double")
#select fieldname1 > 0
#Create Loop and List to run processing for
for field in fields:
#select counties each field has attribute values > 0
#select field1 > 0
arcpy.SelectLayerByAttribute_management ("counties_edited_datamergetest", "NEW_SELECTION", "'" + str(field) + "'" ' > 0')
# export current to jpg such that the name of the file is field1
mxd = arcpy.mapping.MapDocument(r"CURRENT")
arcpy.mapping.ExportToJPEG(mxd, r"P:\CoWetlandTools\maps\"'" + str(field) + "'.jpg")
#clear selected attributes
arcpy.SelectLayerByAttribute_management ("counties_edited_datamergetest", "CLEAR_SELECTION")
#finished
print "Finished"
' " ' + str(field) + ' " > 0 '
import arcpy mxd = arcpy.mapping.MapDocument(r"H:\GIS_Data\junk.mxd") fields = arcpy.ListFields(r"H:\GIS_Data\TEMP.gdb\file", None , "SmallInteger") for field in fields: for lyr in arcpy.mapping.ListLayers(mxd, "file", arcpy.mapping.ListDataFrames(mxd)[0]): arcpy.SelectLayerByAttribute_management (lyr, "NEW_SELECTION", '"' + field.name + '" > 0') arcpy.mapping.ExportToJPEG(mxd, r"H:\GIS_Data\map_" + field.name + ".jpg") arcpy.SelectLayerByAttribute_management (lyr, "CLEAR_SELECTION")
#Script to create distribution maps for wetland species #Import arcpy and set workspace import arcpy import arcpy.mapping mxd = arcpy.mapping.MapDocument (r"P:\CoWetlandTools\maps\distribution_maps_Johns_pytest.mxd") #list object that is the list of fields in our table #List fields and generate a list fields = arcpy.ListFields(r"Y:\John_N\Wetland_field_guide_distribution_maps\counties_datamerge.gdb\counties_edited_datamergetest" , None , "Double") #select fieldname1 > 0 #Create Loop and List to run processing for for field in fields: for lyr in arcpy.mapping.ListLayers (mxd, "file" , arcpy.mapping.ListDataFrames (mxd) [0]): #select counties each field has attribute values > 0 #select field1 > 0 arcpy.SelectLayerByAttribute_management (lyr, "NEW_SELECTION", '"' + field.name + '" > 0') # export current to jpg such that the name of the file is field1 arcpy.mapping.ExportToJPEG(mxd, r"P:\CoWetlandTools\maps\map_ " + field.name + ".jpg") #clear selected attributes arcpy.SelectLayerByAttribute_management (lyr, "CLEAR_SELECTION") #finished print "Finished"
for lyr in arcpy.mapping.ListLayers (mxd, "file" , arcpy.mapping.ListDataFrames (mxd) [0]):The above line means, "list all of the layers named 'file' from the first data frame in the map, 'mxd' ". Change 'file' to be the name of your layer in the map.