I am trying to read a multi-band image in a python code. My requirement is to form a neighborhood matrix. So I need to pad the matrix with with some number so as to be able to form neighborhood for each element. Ex. a is a matrix, padding with 0
a= |1 2 3 |
|4 5 6 |
|7 8 9 |
neighborhood matrix = |0 0 0|
|0 1 2|
|0 4 5|
I am using numpy.pad(below) for this and it works perfectly with single band. But for multi-band, it converts noDataValue to its equivalent in 0-255 and pads with it, which I do not want.
pixels = np.pad(a, (padding,padding), mode='constant', constant_values=(noDataValue))
where padding = 1, noDataValue = -999.0 but it automatically converting it to 125. And this is happening only for multiband. So any help would be appreciated.
Or
If I can pad matrix with a string, that would be great. I could not find any function that helps padding with String.
Update 1:
