[GRASS-user] Extract single pixels with r.mapcalc?
glynn at gclements.plus.com
Tue Jan 18 15:12:11 EST 2011
> Based on one raster map, i want to create a new map containing only eight
> cells - four in the corners of the map and four on the middle of the edges -
> with the category „1”. All other cells are supposed to be NULL-cells.
> I thought about doing this via r.mapcalc - yet i do not know if there is any
> possibility to manipulate only single cells with this command.
It's possible, although r.in.xyz may be a better choice.
To do it in r.mapcalc:
eval `g.region -g`
outmap = if((row() == 1 || row() == $rows/2 || row() == $rows) && \
(col() == 1 || col() == $cols/2 || col() == $cols) && \
!(row() == $rows/2 && col() == $cols/2), 1, null())
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user