Skip to content

r.quantile.ref

Determines quantile for input value from reference raster map layers.

r.quantile.ref [-z] input=name [reference=name [,name,...]] [file=name] output=name [range=lo,hi] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]

Example:

r.quantile.ref input=name output=name

grass.script.run_command("r.quantile.ref", input, reference=None, file=None, output, range=None, flags=None, overwrite=None, verbose=None, quiet=None, superquiet=None)

Example:

gs.run_command("r.quantile.ref", input="name", output="name")

grass.tools.Tools.r_quantile_ref(input, reference=None, file=None, output, range=None, flags=None, overwrite=None, verbose=None, quiet=None, superquiet=None)

Example:

tools = Tools()
tools.r_quantile_ref(input="name", output="name")

This grass.tools API is experimental in version 8.5 and expected to be stable in version 8.6.

Parameters

input=name [required]
    Name of input raster map
reference=name [,name,...]
    List ofreference raster maps
file=name
    Input file with one reference raster map name per line
output=name [required]
    Name for output raster map
range=lo,hi
    Ignore values outside this range
-z
    Do not keep files open
--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

input : str, required
    Name of input raster map
    Used as: input, raster, name
reference : str | list[str], optional
    List ofreference raster maps
    Used as: input, raster, name
file : str, optional
    Input file with one reference raster map name per line
    Used as: input, file, name
output : str, required
    Name for output raster map
    Used as: output, raster, name
range : tuple[float, float] | list[float] | str, optional
    Ignore values outside this range
    Used as: lo,hi
flags : str, optional
    Allowed values: z
    z
        Do not keep files open
overwrite : bool, optional
    Allow output files to overwrite existing files
    Default: None
verbose : bool, optional
    Verbose module output
    Default: None
quiet : bool, optional
    Quiet module output
    Default: None
superquiet : bool, optional
    Very quiet module output
    Default: None

input : str | np.ndarray, required
    Name of input raster map
    Used as: input, raster, name
reference : str | list[str], optional
    List ofreference raster maps
    Used as: input, raster, name
file : str | io.StringIO, optional
    Input file with one reference raster map name per line
    Used as: input, file, name
output : str | type(np.ndarray) | type(np.array) | type(gs.array.array), required
    Name for output raster map
    Used as: output, raster, name
range : tuple[float, float] | list[float] | str, optional
    Ignore values outside this range
    Used as: lo,hi
flags : str, optional
    Allowed values: z
    z
        Do not keep files open
overwrite : bool, optional
    Allow output files to overwrite existing files
    Default: None
verbose : bool, optional
    Verbose module output
    Default: None
quiet : bool, optional
    Quiet module output
    Default: None
superquiet : bool, optional
    Very quiet module output
    Default: None

Returns:

result : grass.tools.support.ToolResult | np.ndarray | tuple[np.ndarray] | None
If the tool produces text as standard output, a ToolResult object will be returned. Otherwise, None will be returned. If an array type (e.g., np.ndarray) is used for one of the raster outputs, the result will be an array and will have the shape corresponding to the computational region. If an array type is used for more than one raster output, the result will be a tuple of arrays.

DESCRIPTION

r.quantile.ref computes for each pixel the quantile ranking of the input value against the reference maps: values of 0, 0.5 and 1.0 respectively indicate that the input value corresponds with the minimum, median or maximum of the reference values. A value of -1 is assigned if the input value is smaller than the minimum and a value of 2 is assigned if the input value is larger than the maximum.

r.quantile.ref can be regarded as the inverse of r.series method=quantile: while r.series calculates the value for a given quantile, r.quantile.ref calculates the quantile for a given value. This is useful to compare e.g. current environmental conditions to a time series of historical environmental conditions.

EXAMPLE

Create some reference rasters:

r.mapcalc "ref1 = 1"
r.mapcalc "ref2 = 2"
r.mapcalc "ref3 = 3"
r.mapcalc "ref4 = 5"
r.mapcalc "ref5 = 5"
r.mapcalc "ref6 = 5"

Create a test raster with cell value 4.5:

r.mapcalc "test = 4.5"

Get the quantile of the test raster for the reference maps:

r.quantile.ref input=test reference=ref1,ref2,ref3,ref4,ref5,ref6 output=test_quant

The quantile corresponding to the value 4.5 is 0.55. Create a test raster with cell value 5:

r.mapcalc "test = 5"

Get the quantile of the test raster for the reference maps:

r.quantile.ref input=test reference=ref1,ref2,ref3,ref4,ref5,ref6 output=test_quant

The quantile corresponding to the value 5 is 0.8.

SEE ALSO

r.quantile, r.series

AUTHOR

Markus Metz

SOURCE CODE

Available at: r.quantile.ref source code (history)
Latest change: Thursday Feb 20 13:02:26 2025 in commit 53de819