[GRASS-user] How to initialize raster maps.

Glynn Clements glynn at gclements.plus.com
Sun Dec 11 13:53:11 EST 2011

Marcello Gorini wrote:

> I use r.mapcalc to create maps that serve as counters such as
> the command i++ in C.

Raster maps aren't supposed to be modified in-place; that applies to
all raster commands, not just r.mapcalc.

At the moment, you will usually get away with it, because:

1. the actual raster data is written to a temporary file, which
replaces the original file when the map is closed, and

2. the support files (cellhd, categories, colour table, etc) are
normally opened, read into (or written from) memory, then closed,
rather than being held open.

However: you won't necessarily get away with it if you're using
GDAL-linked maps (r.external, r.external.out), as those are likely to
be overwritten in place.

If we eventually change the raster format in 7.x, there's a chance
that older formats will be supported by this mechanism. Even if we
support multiple versions natively, fixing issues with concurrent
access is on the agenda, and that may end up breaking in-place

IOW, when I say that in-place modification is "not guaranteed" to
work, I mean that there are reasons to suspect that it may actually
fail in specific cases now, and in the general case in the future.

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-user mailing list