I have turned a geotiff LiDAR elevation surface into a numpy array by the below code:
example_array = np.array(geotiff_surface)
The array is hundreds of values by hundreds of values but could be simplified into an example below:
example_array = [[ 0, 0, 0, 1, 1, 0, 0, 0]
[ 0, 0, 2, 2, 2, 2, 0, 0]
[ 0, 3, 3, 3, 3, 0, 0, 0]
[ 4, 4, 4, 4, 4, 4, 0, 0]
[ 0, 0, 0, 5, 5, 0, 0, 0]]
with the help of others I am trying to slice the 2D array to increase the values at specific locations by 1000 with the code below:
sub_array = example_array[1:-1, 1:-1]
sub_array = [sub_array > 1] += 1000
in hopes to get the below correct example array:
correct_example_array = [[ 0, 0, 0, 1, 1, 0, 0, 0]
[ 0, 0, 2, 1002, 1002, 2, 0, 0]
[ 0, 3, 1003, 1003, 3, 0, 0, 0]
[ 4, 1004, 1004, 1004, 1004, 4, 0, 0]
[ 0, 0, 0, 5, 5, 0, 0, 0]]
when in reality what my current code gives me is this array:
incorrect_example_array = [[ 0, 0, 0, 1, 1, 0, 0, 0]
[ 0, 0, 1002, 1002, 1002, 1002, 0, 0]
[ 0, 1003, 1003, 1003, 1003, 0, 0, 0]
[ 4, 1004, 1004, 1004, 1004, 1004, 0, 0]
[ 0, 0, 0, 5, 5, 0, 0, 0]]
Is there a way to get the slice to understand to skip the zeros in the lists and start slicing [1:-1] within values greater than 1?