GRASS logo

NAME

t.rast.udf - Apply a user defined function (UDF) to aggregate a time series into a single output raster map

KEYWORDS

temporal, aggregation, raster, time

SYNOPSIS

t.rast.udf
t.rast.udf --help
t.rast.udf inputs=name[,name,...] output=name basename=name pyfile=name [nrows=integer] [where=sql_query] [--overwrite] [--help] [--verbose] [--quiet] [--ui]

Flags:

--overwrite
Allow output files to overwrite existing files
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--ui
Force launching GUI dialog

Parameters:

inputs=name[,name,...] [required]
Name of the input space time raster datasets
output=name [required]
Name of the output space time raster dataset
basename=name [required]
The basename of the output raster maps
pyfile=name [required]
The Python file with user defined function to apply to the input STRDS and create an output raster map
nrows=integer
Number of rows that should be provided at once to the user defined function
Default: 1
where=sql_query
WHERE conditions of SQL statement without 'where' keyword used in the temporal GIS framework
Example: start_time > '2001-01-01 12:30:00'

Table of contents

DESCRIPTION

This module is designed to apply a user defined Python function (UDF) to a raster time series (STRDS). This module will accept a single STRDS as input and will generate a single STRDS as output.

The user defined function must follow the API definition provided by the openEO UDF API initiative.

This module requires the openEO UDF API installed in the python path. It also requireds python3.7 to run.

EXAMPLES

Compute the sum of all (x,y) slices in the time series cube along the time axis (0):
def rct_sum(udf_data):
    tile_results = []

    for tile in udf_data.raster_collection_tiles:
        tile_sum = numpy.sum(tile.data, axis=0)
        rows, cols = tile_sum.shape
        array3d = numpy.ndarray([1, rows, cols])
        array3d[0] = tile_sum
        if tile.start_times is not None and tile.end_times is not None:
            starts = pandas.DatetimeIndex([tile.start_times[0]])
            ends = pandas.DatetimeIndex([tile.end_times[-1]])
        else:
            starts = None
            ends = None

        rct = RasterCollectionTile(id=tile.id + "_sum", extent=tile.extent, data=array3d,
                                   start_times=starts, end_times=ends)
        tile_results.append(rct)
    udf_data.set_raster_collection_tiles(tile_results)

rct_sum(data)

AUTHOR

Sören Gebbert

SOURCE CODE

Available at: t.rast.udf source code (history)

Accessed: Monday Jul 27 12:30:28 2026


Main index | Temporal index | Topics index | Keywords index | Graphical index | Full index

© 2003-2026 GRASS Development Team, GRASS 8.5.1dev Reference Manual