When using this code
for i in range(len(data)):
if Ycoord >= Y_west and Xcoord == X_west:
flag = 4
I get this ValueError
if Ycoord >= Y_west and Xcoord == X_west: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
then i use the above restriction
Any help on how i can keep my restriction and go on with the writing of my file?
The variables
Ycoord
andXcoord
are probablynumpy.ndarray
objects. You have to use the array compatibleand
operator to check all its values for your condition. You can create a flag array and set the values to4
in all places where your conditional isTrue
:or you have to test value-by-value in your code doing: