I'm building a Python toolbox with a tool which calls specific functions from a custom module.

The main input parameter for this tool is a multivalue list of raster layers.

In the execute block of my tool, I use parameter[2].valueAsText to read in said parameter, as normal, and then feed it into a custom module function as follows:

output          = parameters[0].valueAsText
input           = parameters[2].valueAsText
function        = parameters[1].valueAsText
functionname    = "Local" + function
option          = parameters[3].valueAsText
expression      = parameters[4].valueAsText

newGrid = getattr(localfuncs,functionname)(input,option,expression)

In this case, I've tested it with one custom function (corresponding to 'functionname'):

def LocalMean(input,option,expression):
    import arcpy
    newGrid = arcpy.sa.CellStatistics(input,"MEAN")
    return newGrid

The trouble is that the 'input' (multivalue read in as text) ends up being a semicolon-delimited string of file names, and the function in the custom module can't seem to convert it back to a list of raster layers for Cell Statistics to actually process. As a result I get this ERROR 000732:

Script failed because:      ERROR 000732: Input Raster: Dataset Development;Vegetation;Hydrology;Elevation does not exist or is not supported at this location: 

I've tried reading in 'input' with .values instead of .valueAsText, so it comes in as a list, but then I get the error that 'cannot concatenate 'str' and 'list' objects' in the getattr line.

Any ideas what I can do about this?

  • I know this overall structure may seem unnecessarily complicated; but it's a key part of the bigger project. I'm not attached to specifically using getattr here, but solutions which preserve the basic structure, namely calling functions from a custom module using a string of the function's name, would be ideal

1 Answer 1


Try using ' '.join(parameters[2].values). It will give you space delimited string instead. Alternately, map them to raster objects with value_list = [arcpy.Raster(val) for val in parameters[2].values]

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.