I have a raster layer with 3 bands
band1 - elevation data
band2 - x-coord
band3 - y-coord
I want to run a grid of 9*9 cells over this raster layer staring from top-left to bottom-right row-wise and to get the peak (highest altitude) out of the neighboring cells in the current 9*9 grid and put that peak into a 2D-matrix which contains XY coordinate of the corresponding peak after completing the iteration, I will be left with a matrix of coordinates I came to know that grid function from raster package in R will be useful any more methods.