I have read two bands from a remote sensed image and I want to subtract them. If the difference is greater than a threshold, I want the output to be 1, otherwise 0. Yet, this error keeps popping up The truth value of an array with more than one element is ambiguous. Use a.any() or a.all(). Below the lines of code are illustrated.
red_array = red.ReadAsArray()
swir1_array = swir1.ReadAsArray()
# Substracting the bands creating a raster that enhances ships ready for classification
# red_swir = np.where(((red_array > 2000) & (swir1_array > 900)), 0, red_array - swir1_array).astype(np.int16)
difference = (red_array - swir1_array).astype(np.int16)
red_swir = np.where((difference > 2000, 1, 0))
Any help here?