1

I have a large shapefile and I'm trying to automate a process to generate histograms of several fields with the MakeGraph tool, but I'm receiving the following error.

class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 001020: Input series error. Incompatible parameter list. Click 'Always reset parameters...' check-box to reset parameters. Failed to execute (MakeGraph).

Any idea why this is happening? My inputs are as follows...

  • input table = shapefile,
  • fieldList is generated by input,
  • workspace = output folder,
  • input_template = a .grf or .tee (tried both),
  • run is just a boolean true or false

Here's my code:

# Import arcpy module
import arcpy
# Check out any necessary licenses
arcpy.CheckOutExtension("spatial")
input_table = arcpy.GetParameterAsText(0)
fieldList = arcpy.GetParameterAsText(1)
workspace = arcpy.GetParameterAsText(2)
arcpy.env.workspace = workspace
input_template = arcpy.GetParameterAsText(3)
run = arcpy.GetParameterAsText(4)
countBin = 10
# Boolean selection
if run == 'true':
 # Iterate over selected field names
 for fieldName in fieldList.split(';'):
 out_graph_name = "histogram" 
 out_graph_jpg = fieldName + "_histogram.jpg" 
 # Create the graph 
 graph = arcpy.Graph() 
 # Add a histogram series to the graph 
 graph.addSeriesHistogram(input_table, fieldName, countBin) 
 # Specify the title of the left axis 
 graph.graphAxis[0].title = "Count" 
 # Specify the title of the bottom axis 
 graph.graphAxis[2].title = fieldName 
 # Specify the title of the Graph 
 graph.graphPropsGeneral.title = fieldName + " Histogram" 
 # Output a graph, which is created in-memory 
 arcpy.MakeGraph_management(input_template, graph, out_graph_name) 
 # Save the graph as an image 
 arcpy.SaveGraph_management(out_graph_name, out_graph_jpg, "MAINTAIN_ASPECT_RATIO", 600, 375)
else:
 print "done"
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Nov 2, 2014 at 22:38
2
  • you mention the fieldlist is generated by input - can you verify that the fieldname is in the input table during the loop? Commented Nov 3, 2014 at 0:50
  • fieldList is a field parameter with multivalues obtained from the shapefile and fieldName is each of the field names that are selected Commented Nov 3, 2014 at 2:02

1 Answer 1

2

Your issue is here I believe:

graph.addSeriesHistogram(input_table, fieldName, countBin)

Specifically, with the variable fieldName. For addSeriesHistogram, fieldNameneeds to be a layer object. Instead, it is a string in your code. To access the layer object, you'll need to use arcpy.ListLayers.

Try this code:

#Create map object
mxd = arcpy.mapping.MapDocument("CURRENT") 
#iterate through layer objects in map object
for lyr in arcpy.mapping.ListLayers(mxd):
 #Find layer with name 'fieldName'
 if lyr.name == fieldName: 
 graph.addSeriesHistogram(input_table, lyr, countBin)
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
answered Dec 28, 2014 at 2:45

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.