[GRASS-user] Extract single pixels with r.mapcalc?

Hello Grass users!

I have the following problem:

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 all comes down to the question if one cell in a GRASS raster layer
actually contains information about its coordinates;(which i could include
in a r.mapcalc command) - or if it is really only defined by the edges of
the map, the resolution and the resulting number of cells?

Sorry for the sort of noobish question, i think i don't yet have complete
understanding of the GRASS raster format, though i read the related manual
pages.

I also know that i can reach the same result by simply digitizing a vector
map with the points in question, then running v.to.rast. But as i want to
make this operation part of a shell script, i'm eager to avoid (1) most
interactive operations and (2) the way to the vector format and back again.
Point 1 i could of course avoid by using v.edit, but there is still point 2.

Would be glad for any help!
Thanks,
Levent
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Extract-single-pixels-with-r-mapcalc-tp5935168p5935168.html
Sent from the Grass - Users mailing list archive at Nabble.com.

LeventB wrote:

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`
r.mapcalc <<EOF
outmap = if((row() == 1 || row() == $rows/2 || row() == $rows) && \
            (col() == 1 || col() == $cols/2 || col() == $cols) && \
            !(row() == $rows/2 && col() == $cols/2), 1, null())
EOF

--
Glynn Clements <glynn@gclements.plus.com>

Thank you!
I just overlooked r.in.xyz, but it does a really good job; so i will stick
to this command.
Greetings,
Levent
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Extract-single-pixels-with-r-mapcalc-tp5935168p5976458.html
Sent from the Grass - Users mailing list archive at Nabble.com.