r.mapcalc.tiled
Runs r.mapcalc in parallel over tiles.
r.mapcalc.tiled expression=string [output=name] [width=integer] [height=integer] overlap=integer [nprocs=integer] [processes=integer] [mapset_prefix=string] [patch_backend=string] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]
Example:
r.mapcalc.tiled expression=string overlap=0
grass.script.run_command("r.mapcalc.tiled", expression, output=None, width=None, height=None, overlap=0, nprocs=None, processes=None, mapset_prefix=None, patch_backend=None, overwrite=False, verbose=False, quiet=False, superquiet=False)
Example:
gs.run_command("r.mapcalc.tiled", expression="string", overlap=0)
Parameters
expression=string [required]
Expression to send to r.mapcalc
output=name
Name of raster output map resulting from expression
width=integer
Width of tiles (columns)
height=integer
Height of tiles (rows)
overlap=integer [required]
Overlap of tiles
Default: 0
nprocs=integer
Number of r.mapcalc processes to run in parallel
Allowed values: 1-
processes=integer
This option is obsolete and replaced by nprocs
Number of r.mapcalc processes to run in parallel, use nprocs option instead
Allowed values: 1-
mapset_prefix=string
Mapset prefix
patch_backend=string
Backend for patching computed tiles
If backend is not specified, original serial implementation with RasterRow is used
Allowed values: RasterRow, r.patch
RasterRow: serial patching with PyGRASS RasterRow
r.patch: parallelized r.patch (with zero overlap only)
--overwrite
Allow output files to overwrite existing files
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--qq
Very quiet module output
--ui
Force launching GUI dialog
expression : str, required
Expression to send to r.mapcalc
output : str, optional
Name of raster output map resulting from expression
Used as: output, raster, name
width : int, optional
Width of tiles (columns)
height : int, optional
Height of tiles (rows)
overlap : int, required
Overlap of tiles
Default: 0
nprocs : int, optional
Number of r.mapcalc processes to run in parallel
Allowed values: 1-
processes : int, optional
This option is obsolete and replaced by nprocs
Number of r.mapcalc processes to run in parallel, use nprocs option instead
Allowed values: 1-
mapset_prefix : str, optional
Mapset prefix
patch_backend : str, optional
Backend for patching computed tiles
If backend is not specified, original serial implementation with RasterRow is used
Allowed values: RasterRow, r.patch
RasterRow: serial patching with PyGRASS RasterRow
r.patch: parallelized r.patch (with zero overlap only)
overwrite: bool, optional
Allow output files to overwrite existing files
Default: False
verbose: bool, optional
Verbose module output
Default: False
quiet: bool, optional
Quiet module output
Default: False
superquiet: bool, optional
Very quiet module output
Default: False
DESCRIPTION
r.mapcalc.tiled cuts a raster input map into tiles and runs r.mapcalc over these tiles before patching the result together into a single output raster map.
The user provides the map calculation expression. The output map name is automatically extracted from that expression by extracting the string before the '='. If the expression is more complex, the user can also provide the the output map name with the parameter output
Tiles can be defined with the width, height and overlap parameters. If no width and height is specified, they are automatically computed from the number of processes and current computational region (with GRASS GIS v8.2 and above). For example, 8 processes result in 8 tiles where the tile width is equal to the number of columns. If nprocs is higher than one, these tiles will be processed in parallel.
The mapset_prefix parameter ensures that the temporary mapsets created during the tiled processing have unique names. This is useful if the user runs r.mapcalc.tiled several times in parallel (e.g. in an HPC environment).
Option patch_backend can switch how the resulting tiles are merged. With patch_backend=RasterRow (default) the original GridModule implementation is used. With patch_backend=r.patch module r.patch is used with the number of cores specified with nprocs. This backend can only be used with 0 overlap.
EXAMPLE
Run r.mapcalc over tiles with size 1000x1000 using 4 parallel processes (North Carolina sample dataset):
g.region raster=ortho_2001_t792_1m
r.mapcalc.tiled expression="bright_pixels = if(ortho_2001_t792_1m > 200, 1, 0)" \
width=1000 height=1000 nprocs=4
SEE ALSO
AUTHOR
Moritz Lennert
SOURCE CODE
Available at: r.mapcalc.tiled source code
(history)
Latest change: Thursday Feb 20 13:02:26 2025 in commit 53de819