I need to get rid of the border points in an array which came from a raster. I first converted my GeoTiff to numpy array using:
input = gdal.Open("file.tif") array = np.array(input.GetRasterBand(1).ReadAsArray())
Then I want to remove the boundary pixels, so that one column and one row (so two of each totaling four lines) are subtracted in the final array. This is because I need to keep applying functions which cannot use these boundary pixels. So I did the following:
window =  for row in range(1): for col in range(1): window.append(array[row:(array.shape - 2), col:(array.shape - 2)])
Next I converted this new list into a numpy array via newarray = np.array(window)
Originally I had a total of points = 140, with 14 rows and 10 columns. And if I print the newarray to the console my new total is 96 points, which is expected. But if I check the number of rows and columns in this new array via
print newarray.shape, newarray.shape
then my resulting structure shows that I only have 1 row and 12 columns. How does this make sense? I should have 12 rows and 8 columns... Is the formula for getting rid of the bounding pixels incorrect, or is there a different and more efficient way to do this and remove the bordering pixels from each side of the array?