I have a Land Cover classification map that I created from 2m resolution multispectral imagery and I am trying to downsample the results to a 20m resolution class map.
The climate in question is arid so there are many areas with sparse shrubs or trees. As such, one 2m resolution class may have a couple of pixels for a single shrub. I am not interested in where each individual tree or bush is, but rather where there are areas of high concentration of a given class (i.e. I want to create a 20m resolution class map that will aggregate the high resolution classes into classes such as "sparse shrubs" or "dense shrubs" depending on the density of 2m x 2m shrub classes found in the 20m x 20m grid square)
Using r.mapcalc in GRASS GIS I know you can refer to neighboring cells using the format map[1,-2] and there are many useful functions available in r.mapcalc. However, my problem is that when I am downsampling to ~20m resolution from 2m resolution there are ~100 neighbors to analyze and I would have to address each one specifically as there is no way that I have found to nest a for loop within a call to r.mapcalc.
Does anyone have suggestions on a way to gather statistics of the cells surrounding a given map cell, and change the cell in question based on its neighbors in the way I describe?