I have a .tif that I read into an array (call it tifArray), and I would like to classify the array based on set of conditions:
- Where 1200 <= tifArray <= 4000, outputArray = 1
- Where tifArray < 1200, outputArray = 2
- Where tifArrary > 4000, outputArray = 3
I've tried both creating a new array (preferred) and replacing the values in place (see below) but I regardless I get a MemoryError. I've tried on machines that have 10 and 8 GB of free RAM. I've also tried using the np.where function and just plain indexing (below). I have no clue why I'm getting a memory error, and I don't think I should be running into that problem.
Some information about tifArray:
tifArray.shape = (55500, 55500) tifArray.dtype = uint16
And here is one method I tried:
threshold_low = 1200 threshold_high = 4000 tifArray[(tifArray >= threshold_low) & (tifArray <= threshold_high)] = 1 tifArray[(tifArray < threshold_low)] = 2 tifArray[(tifArray > threshold_high)] = 3
File "./classify_segmented_fromAmplitude.py", line 90, in process_tile tifArray[(tifArray >= threshold_low) & (tifArray <= threshold_high)] = 1 MemoryError
When I comment out the first condition:
tifArray[(tifArray >= threshold_low) & (tifArray <= threshold_high)] = 1
and just run the following two lines, I get no Memory Error. So obviously the problem is with the multiple conditions, but I don't know how to get around it. Any ideas?