I have an elevation array from a .tif LiDAR surface. Example array below.
Existing_example_arrayV0 = [[ 0, 0, 1, 0, 0, 0, 0],
[ 0, 1, 1, 1, 0, 0, 0],
[ 0, 1, 1, 1, 1, 0, 0],
[ 1, 1, 1, 1, 1, 0, 0],
[ 0, 1, 1, 1, 1, 0, 0],
[ 0, 1, 1, 0, 0, 0, 0]]
I am attempting to use scipy.ndimage to iterate over the array and add 100 to the array.
Existing_example_arrayV0[binary_erosion(Existing_example_arrayV0 >=1, structure=[[1,1,1]])] += 100
to produce the first iteration.
Existing_example_arrayV1 = [[ 0, 0, 1, 0, 0, 0, 0],
[ 0, 1, 100, 1, 0, 0, 0],
[ 0, 1, 100, 100, 1, 0, 0],
[ 1, 100, 100, 100, 1, 0, 0],
[ 0, 1, 100, 100, 1, 0, 0],
[ 0, 1, 1, 0, 0, 0, 0]]
I'm not familiar with Binary Erosion so I am having a difficult time iterating to create the second iteration:
Existing_example_arrayV2 = [[ 0, 0, 1, 0, 0, 0, 0],
[ 0, 1, 100, 1, 0, 0, 0],
[ 0, 1, 100, 100, 1, 0, 0],
[ 1, 100, 200, 100, 1, 0, 0],
[ 0, 1, 100, 100, 1, 0, 0],
[ 0, 1, 1, 0, 0, 0, 0]]
I attempted to create a for
loop that would create the next step but am having issues getting it to run correctly.
import scipy.ndimage as binary_erosion
for i in range(0,1):
binary_erosion(Existing_example_arrayV1>=1, structure=[[1,1,1]], iterations = i + 1)
I thought the range would just run the next iteration to produce Existing_example_arrayV2
, but it is not.
I am trying to add an iteration on top of the finished numpy array (V0 -> V1, V1 -> V2 etc.) to continue the cycle for however many iterations I need to run.