In ArcMap 10.2 I have created a nested model where I am iterating through some feature classes in order to get the minimum value of a specific field for each of them and then collect the outputs using the Collect Values Tool. The output is named Zminand for whatever reason it is a string.

Afterwards I want to get the minimum of these minima in order to use it as parameter in a following step of the main model.

I have tried to use the Calculate Value Tool as follows:



Code Block:

def lowest(Zmin):
    LowestLine = min(Zmin)
    return LowestLine

Data Type: Double

Unfortunately I get the following error message:

ValueError: invalid literal for float(): -129.8;-119.4;-118.9;-157.3

My knowledge of Python is not really deep, however the problem is obviously in the type of the input. I tried to split it into a list of strings by using Zmin.split(';')

before to convert it into floating points, but this is probably the wrong way and I do not know how to solve it.


You need to have an array of minima and then convert the individual values to floats before running min. Try this:

def lowest(Zmin):
    # assign the split string to an array
    minima = Zmin.split(';')

    # iterate through the array and convert each element to float
    for idx,value in enumerate(minima):
        minima[idx] = float(minima[idx])

    # determine the minimum value
    LowestLine = min(minima)
    return LowestLine
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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