Skip to content

r.mask.status

Reports presence or absence of a raster mask

Provides information about the presence of a 2D raster mask as text output or return code

r.mask.status [-t] [format=string] [--verbose] [--quiet] [--qq] [--ui]

Example:

r.mask.status

grass.script.parse_command("r.mask.status", format="plain", flags=None, verbose=False, quiet=False, superquiet=False)

Example:

gs.parse_command("r.mask.status")

Parameters

format=string
    Format for reporting
    Allowed values: plain, json, shell, yaml
    Default: plain
    plain: Plain text output
    json: JSON (JavaScript Object Notation)
    shell: Shell script style output
    yaml: YAML (human-friendly data serialization language)
-t
    Return code 0 when mask present, 1 otherwise
    Behave like the test utility, 0 for true, 1 for false, no output
--help
    Print usage summary
--verbose
    Verbose module output
--quiet
    Quiet module output
--qq
    Very quiet module output
--ui
    Force launching GUI dialog

format : str, optional
    Format for reporting
    Allowed values: plain, json, shell, yaml
    plain: Plain text output
    json: JSON (JavaScript Object Notation)
    shell: Shell script style output
    yaml: YAML (human-friendly data serialization language)
    Default: plain
flags : str, optional
    Allowed values: t
    t
        Return code 0 when mask present, 1 otherwise
        Behave like the test utility, 0 for true, 1 for false, no output
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

The r.mask.status reports information about the 2D raster mask and its status. The tool reports whether the mask is present or not. For both active and inactive mask, the tool reports a full name of the raster (name including the mapset) which represents or would represent the mask. It can also report full name of the underlying raster if the mask is reclassified from another raster. The tool can be used to check if the mask is currently set (present boolean in JSON), what is raster name used to represent the mask (name string in JSON), and whether the raster is reclassifed from another (is_reclass_of string or null in JSON). YAML and shell script style outputs are following the JSON output if possible. The plain text format outputs multi-line human-readable information in natural language.

With the -t flag, no output is printed, instead a return code is used to indicate presence or absence. The convention is the same same the POSIX test utility, so r.mask.status returns 0 when the mask is present and 1 otherwise.

EXAMPLES

Generate JSON output

To generate JSON output in Bash, use the format option:

r.mask.status format=json

In Python, use:

import grass.script as gs
gs.parse_command("r.mask.status", format="json")

This returns a dictionary with keys present, full_name, and is_reclass_of.

Use as the test utility

The POSIX test utility uses return code 0 to indicate presence and 1 to indicate absence of a file, so testing existence of a file with test -f gives return code 0 when the file exists. r.mask.status can be used in the same with the -t flag:

r.mask.status -t

In a Bash script:

# Bash
if r.mask.status -t; then
    echo "Masking is active"
else
    echo "Masking is not active"
fi

SEE ALSO

r.mask, g.region

AUTHORS

Vaclav Petras, NC State University, Center for Geospatial Analytics

SOURCE CODE

Available at: r.mask.status source code (history)
Latest change: Friday Mar 07 07:39:48 2025 in commit e1e37d8