This is my first time using GRASS to work with Rasters, so please excuse my lack of knowledge on the subject.
I want to run the GRASS r.neighbors function on cells that meet a specific criteria, and ignore running the function that do not meet that criteria. In addition, I still want to use the values that do not meet the criteria in the neighborhood calculations.
For example, I have a raster with integer values, and I want cells with a value of 1, 2, and 3 to run the r.neighbors function, but not values of 4, and 5. When the function gets to cells with values of 1, 2, or 3, r.neighbors should run, and include all cells within the neighborhood (even ones with values 4, and 5). When cells of 4, and 5 are encountered, I simply want to do nothing and move to the next cell.
Here is a very similar Knowledge Base article from Esri that does this, but with NoData cells. I need to do it using GRASS.
Looking at the documentation for r.neighbors, I do not see a clear way to approach this. I do not believe I can simply loop through the raster cells and run the r.neighbors function since the output is a new raster each time it run.
If that is the case, then perhaps I can reverse engineer the r.neighbors function within a conditional? I just have no idea how r.neighbors determines it's neighborhood.
- How does r.neighbors walk through the raster collecting cell values?
- If so, then how does it do this?
- Ultimately, this is what I want to know the most!
- Would I be better off trying to do this outside of GRASS?
- If so, what are your recommendations?
Right now, I am just stuck on where to go.
I am most interested in learning how (systematically) r.neighbors collects the neighborhood values. What functions, methods, etc. does GRASS use to read specific cell values within a) a certain number of cells OR b) a specific distance in n direction of a given cell? I believe knowing this will help me the most going forward.