This question is an exact duplicate of:
This Code should produce Maps of each attribute in a Feature Class automatically (ArcGIS 10.1). However, when I run it I get a Value Error for attributes which do include float values. How would I modify the code to make it work for both, float values and integer values.
import arcpy, os #Specify the map document and the data frame mxd = arcpy.mapping.MapDocument("C:\\Users\\\\mxd1.mxd") featureclass = "D:\\\\Testgdb\\Animals_Insects" #output file folder outPath = "D:\\Data\Test3\\" # Run through all attribute fields in selected featureclass - do not produce maps for the first 19 and the last 2 fields attrlist = [f.name for f in arcpy.ListFields(featureclass)] attrlist = attrlist[19:len(attrlist)-5] # layer which has to change the attribute field featurelayer = arcpy.mapping.ListLayers(mxd, "Animals_Insects")[0] # text element that has to change (e.g. title...) title = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "map_title")[0] for attr in attrlist: #if featurelayer.symbologyType == "GRADUATED_COLORS": # change value field featurelayer.symbology.valueField = attr # change tilte title.text = attr # update view arcpy.RefreshActiveView() arcpy.RefreshTOC() # export as jpeg #outJPEG = os.path.join(outPath, attr + ".jpg") arcpy.mapping.ExportToJPEG(mxd, outJPEG, "PAGE_LAYOUT", 200, 200, 300, False, "24-BIT_TRUE_COLOR", 90, False) # export as AdobeIllustrator .ai #outAI = os.path.join(outPath, attr + ".ai") #arcpy.mapping.ExportToAI(mxd, outAI, "PAGE_LAYOUT", 200, 200, 300, "BEST", "RGB", "VECTORIZE_BITMAP", False)del mxd
أكثر...
This Code should produce Maps of each attribute in a Feature Class automatically (ArcGIS 10.1). However, when I run it I get a Value Error for attributes which do include float values. How would I modify the code to make it work for both, float values and integer values.
import arcpy, os #Specify the map document and the data frame mxd = arcpy.mapping.MapDocument("C:\\Users\\\\mxd1.mxd") featureclass = "D:\\\\Testgdb\\Animals_Insects" #output file folder outPath = "D:\\Data\Test3\\" # Run through all attribute fields in selected featureclass - do not produce maps for the first 19 and the last 2 fields attrlist = [f.name for f in arcpy.ListFields(featureclass)] attrlist = attrlist[19:len(attrlist)-5] # layer which has to change the attribute field featurelayer = arcpy.mapping.ListLayers(mxd, "Animals_Insects")[0] # text element that has to change (e.g. title...) title = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "map_title")[0] for attr in attrlist: #if featurelayer.symbologyType == "GRADUATED_COLORS": # change value field featurelayer.symbology.valueField = attr # change tilte title.text = attr # update view arcpy.RefreshActiveView() arcpy.RefreshTOC() # export as jpeg #outJPEG = os.path.join(outPath, attr + ".jpg") arcpy.mapping.ExportToJPEG(mxd, outJPEG, "PAGE_LAYOUT", 200, 200, 300, False, "24-BIT_TRUE_COLOR", 90, False) # export as AdobeIllustrator .ai #outAI = os.path.join(outPath, attr + ".ai") #arcpy.mapping.ExportToAI(mxd, outAI, "PAGE_LAYOUT", 200, 200, 300, "BEST", "RGB", "VECTORIZE_BITMAP", False)del mxd
أكثر...