[GRASS-user] How GRASS loads raster images into memory?
Glynn Clements
glynn at gclements.plus.com
Sat Aug 17 01:49:05 PDT 2013
Andranik Hayrapetyan wrote:
> I would like to understand how GRASS loads raster images into memory to
> perform calculations on them.
> Does it load the entire image into memory and only then do the calculation
> on them, or it loads image into memory by portions sequentially?
The lowest-level read operation reads a specific row into memory. The
lowest-level write operation writes the next row from memory. IOW,
rows can be read in any order but must be written sequentially.
The native GRASS raster format includes a row index, so that rows can
be read out of order, and rows which aren't read can be skipped over.
Modules which need more than one row at a time typically maintain a
sliding window of consecutive rows. This may be done using the rowio
library or within the application code.
Modules which have non-sequential access patterns (e.g. r.proj)
typically create a temporary copy in a format which is more suited to
random access. This may be done using the segment library or within
the application code.
A few modules (e.g. i.fft) read the entire map into contiguous memory.
This is typically restricted to modules where use of a tile cache
isn't practical and/or the algorithmic complexity is such that the
processing time would become a problem before the memory consumption
does.
> Or may be this depends on specific module?
> In particular I am interested in 2 modules: *r.mapcalc* and *r.patch*.
r.patch just uses row-by-row access. r.mapcalc uses the rowio library
if the expression uses a neighbourhood modifier with a vertical
component, otherwise it just uses row-by-row access.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user
mailing list