0

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:

Expression:

lowest("%Zmin%")

Code Block:

def lowest(Zmin):
 Zmin.split(';')
 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.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Jan 16, 2019 at 13:07

1 Answer 1

1

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
answered Jan 16, 2019 at 14:22
0

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.