Skip to content

t.rast.what.aggr

Sample a space time raster dataset at specific vector point map returning aggregate values and write the output to stdout or to attribute table

t.rast.what.aggr [-uac] input=name strds=name [date_column=name] [date=string] [final_date=string] [output=name] [final_date_column=name [,name,...]] [columns=name [,name,...]] [granularity=string] method=string [,string,...] [separator=character] [nprocs=integer] [date_format=string] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]

Example:

t.rast.what.aggr input=name strds=name method=average

grass.script.run_command("t.rast.what.aggr", input, strds, date_column=None, date=None, final_date=None, output="-", final_date_column=None, columns=None, granularity=None, method="average", separator="pipe", nprocs=1, date_format="%Y-%m-%d", flags=None, overwrite=False, verbose=False, quiet=False, superquiet=False)

Example:

gs.run_command("t.rast.what.aggr", input="name", strds="name", method="average")

Parameters

input=name [required]
    Name of input vector map
    Or data source for direct OGR access
strds=name [required]
    Name of the input space time raster dataset
date_column=name
    Name of the column containing starting dates for aggregates
date=string
    The starting date for aggregation
final_date=string
    The end date for aggregation, requires date option
output=name
    Name for the output file or "-" in case stdout should be used
    Default: -
final_date_column=name [,name,...]
    Column with ending date for aggregation, requires date_columns option
columns=name [,name,...]
    Name of attribute column(s)
granularity=string
    Aggregation granularity, format absolute time "x years, x months, x weeks, x days, x hours, x minutes, x seconds" or an integer value for relative time
method=string [,string,...] [required]
    Aggregate operation to be performed on the raster maps
    Allowed values: average, median, mode, minimum, maximum, stddev, sum, variance, quart1, quart3, perc90, quantile
    Default: average
separator=character
    Field separator
    Special characters: pipe, comma, space, tab, newline
    Default: pipe
nprocs=integer
    Number of processes to run in parallel
    Default: 1
date_format=string
    Tha date format
    Default: %Y-%m-%d
-u
    Update attribute table of input vector map
    Instead of creating a new vector map update the attribute table with value(s)
-a
    Query STRDS with dates after the 'date' or 'column_date' value
    Usually t.rast.what.aggr aggregate values before the selected dates, using a flag it will query values after the selected dates
-c
    Create new columns, it combine STRDS and method names
    Create new columns for the selected methods, it combine STRDS and method names
--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 vector map
    Or data source for direct OGR access
    Used as: input, vector, name
strds : str, required
    Name of the input space time raster dataset
    Used as: input, strds, name
date_column : str, optional
    Name of the column containing starting dates for aggregates
    Used as: input, dbcolumn, name
date : str, optional
    The starting date for aggregation
final_date : str, optional
    The end date for aggregation, requires date option
output : str, optional
    Name for the output file or "-" in case stdout should be used
    Used as: output, file, name
    Default: -
final_date_column : str | list[str], optional
    Column with ending date for aggregation, requires date_columns option
    Used as: input, dbcolumn, name
columns : str | list[str], optional
    Name of attribute column(s)
    Used as: input, dbcolumn, name
granularity : str, optional
    Aggregation granularity, format absolute time "x years, x months, x weeks, x days, x hours, x minutes, x seconds" or an integer value for relative time
method : str | list[str], required
    Aggregate operation to be performed on the raster maps
    Allowed values: average, median, mode, minimum, maximum, stddev, sum, variance, quart1, quart3, perc90, quantile
    Default: average
separator : str, optional
    Field separator
    Special characters: pipe, comma, space, tab, newline
    Used as: input, separator, character
    Default: pipe
nprocs : int, optional
    Number of processes to run in parallel
    Default: 1
date_format : str, optional
    Tha date format
    Default: %Y-%m-%d
flags : str, optional
    Allowed values: u, a, c
    u
        Update attribute table of input vector map
        Instead of creating a new vector map update the attribute table with value(s)
    a
        Query STRDS with dates after the 'date' or 'column_date' value
        Usually t.rast.what.aggr aggregate values before the selected dates, using a flag it will query values after the selected dates
    c
        Create new columns, it combine STRDS and method names
        Create new columns for the selected methods, it combine STRDS and method names
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

t.rast.what.aggr samples a space time raster dataset at points from a vector map and returns aggregated values either printing them to stdout or updating the attribute table. A single date for the aggregation can be provided with the option date or alteratively, different dates for each point in the vector map can be passed through the option date_column. Either date or date_column must be provided. The aggregation is done by default backwards in time starting from the date provided and with the granularity set. Alternatively, the data can be aggregated forward in time by using the a flag. By default, the output is printed to stdout. To write the output into the attribute table of the vector map, u flag must be set and the target column should be created beforehand (See v.db.addcolumn). Alternatively, c flag creates the columns using the name of the space time raster dataset (strds) and the method(s) as column name(s).

NOTES

For method=mode the module requires scipy library to be installed.

EXAMPLES

Average NDVI for the previous 2 months starting from 2015-05-01 (i.e.: date="2015-05-01") for all points in the vector map.

t.rast.what.aggr input=GR_GSOM_stations strds=ndvi_16_5600m \
 date=2015-05-01 granularity="2 months"

1|2015-05-01|4480.0
2|2015-05-01|5852.66666667
3|2015-05-01|5683.33333333
4|2015-05-01|4985.0

Average, minimum and maximum NDVI for the previous 2 months starting from 2015-05-01 (i.e.: date="2015-05-01") for all points in the vector map.

t.rast.what.aggr input=GR_GSOM_stations strds=ndvi_16_5600m \
 date=2015-05-01 granularity="2 months" method=average,minimum,maximum

1|2015-05-01|4480.0|4371.0|4545.0
2|2015-05-01|5852.66666667|5618.0|6249.0
3|2015-05-01|5683.33333333|5530.0|5955.0
4|2015-05-01|4985.0|4820.0|5169.0

Average NDVI for the previous 2 months, starting from different dates for each point in the vector map (i.e.: providing date_column).

t.rast.what.aggr input=GR_GSOM_stations strds=ndvi_16_5600m \
 granularity="2 months" date_column=fechas

1|2015-01-01|*
2|2015-02-01|5254.0
3|2015-03-01|6023.66666667
4|2015-04-01|4399.66666667

Minimum and maximum NDVI for the previous 2 months, starting from different dates for each point in the vector map (i.e.: providing date_column).

t.rast.what.aggr input=GR_GSOM_stations strds=ndvi_16_5600m \
 date_column=fechas granularity="2 months" \
 method=minimum,maximum

1|2015-01-01|*|*
2|2015-02-01|5254.0|5254.0
3|2015-03-01|5944.0|6119.0
4|2015-04-01|3786.0|4820.0

Minimum and maximum NDVI for the 2 months after (i.e.: set -a flag) the date provided in date_column. Note that in this example the first point gets populated.

t.rast.what.aggr -a input=GR_GSOM_stations date_column=fechas \
 granularity="2 months" strds=ndvi_16_5600m method=minimum,maximum

1|2015-01-01|3497.0|4280.0
2|2015-02-01|4801.0|6249.0
3|2015-03-01|5530.0|5955.0
4|2015-04-01|5169.0|6390.0

Minimum and maximum NDVI for the previous 2 months, starting from different dates for each point in the vector map (i.e.: providing date_column) and write the output into the vector atrribute's table.

# create columns
v.db.addcolumn map=GR_GSOM_stations column="ndvi_min double precision"
v.db.addcolumn map=GR_GSOM_stations column="ndvi_max double precision"

# write the aggregated values to the attribute table
t.rast.what.aggr -u input=GR_GSOM_stations strds=ndvi_16_5600m \
 date_column=fechas granularity="2 months" columns=ndvi_min,ndvi_max \
 method=minimum,maximum

# check the result
v.db.select map=GR_GSOM_stations

cat|station|name|long|lat|fechas|ndvi_min|ndvi_max
1|GRE00105244|LAMIA|22.4|38.9|2015-01-01||
2|GRE00105246|TANAGRA|23.53|38.32|2015-02-01|5254|5254
3|GRE00105240|CHIOS|26.13|38.33|2015-03-01|5944|6119
4|GRE00105242|FLORINA|21.4|40.78|2015-04-01|3786|4820

Automatically create the columns and populate them with the aggregated values.

t.rast.what.aggr -u -c input=GR_GSOM_stations date_column=fechas \
 granularity="2 months" strds=ndvi_16_5600m method=minimum,maximum

v.db.select map=GR_GSOM_stations
cat|station|name|long|lat|fechas|ndvi_mean|ndvi_max|ndvi_16_5600m_minimum|ndvi_16_5600m_maximum
1|GRE00105244|LAMIA|22.4|38.9|2015-01-01||||
2|GRE00105246|TANAGRA|23.53|38.32|2015-02-01|5254|5254|5254|5254
3|GRE00105240|CHIOS|26.13|38.33|2015-03-01|5944|6119|5944|6119
4|GRE00105242|FLORINA|21.4|40.78|2015-04-01|3786|4820|3786|4820

SEE ALSO

r.what, t.rast.what, t.rast.aggregate

GRASS GIS Wiki: temporal data processing

AUTHORS

Luca Delucchi
Documentation by Veronica Andreo

SOURCE CODE

Available at: t.rast.what.aggr source code (history)
Latest change: Thursday Feb 20 13:02:26 2025 in commit 53de819