Unit 17 - Spatio-temporal intro

GRASS GIS offers specialized tools for spatio-temporal data processing, see GRASS documentation for details.

GRASS introduces three special data types that are designed to handle time-series data:

  • Space-time raster datasets (strds) for managing raster map time series.
  • Space-time 3D raster datasets (str3ds) for managing 3D raster map time series.
  • Space-time vector datasets (stvds) for managing vector map time series.

Spatio-temporal flooding simulation

Module r.lake itself allows to generating only one level (represented by one raster map) within one run. This limitation is surpassed by addon r.lake.series.


Addons modules are not internal part of GRASS installation. Addons can be easily installed by g.extension (Settings ‣ Addons extensions ‣ Install extension from addons).


Fig. 100 Install r.lake.series GRASS Addon.

r.lake.series module outputs multiple raster maps registered in space-time raster dataset.

r.lake.series elevation=dem out=lakes start_water_level=134 end_water_level=145 \
 water_level_step=0.1 coordinates=686668,5650664 \
 time_step=10 nproc=3

In the example above we created space-time series between water levels 134 and 145 with step 0.1 m. Time step is 10 min. To increase computation speed we used three CPU cores. The result is stored in raster space-time dataset named lakes.

Basic information about output space-time dataset can be obtained by t.info command.

t.info input=lakes
+-------------------- Relative time -----------------------------------------+
| Start time:................. 1
| End time:................... 1101
| Relative time unit:......... minutes
| Granularity:................ 10
| Temporal type of maps:...... point

Time topology information can be obtained by t.topology.

t.topology input=lakes
+-------------------- Temporal topology -------------------------------------+
| Number of points: .......... 111
| Number of gaps: ............ 110
| Granularity: ............... 10

Space-time Data Querying

By t.rast.list can be printed raster maps within given time period. In the example below are printed raster maps within the first hour of simulated flooding.

t.rast.list input=lakes order=start_time where="start_time < 60"

Univariate statistic can be calculated by t.rast.univar, in example below statistics is computed only for the first hour of flooding.

t.rast.univar input=lakes where="start_time < 60"

Data aggregation can be performed by t.rast.aggregate. In the example below data is aggregated by 1 hour.

t.rast.aggregate input=lakes output=lakes_h basename=ag granularity=60 nproc=3

The command generates a new space time dataset which can be used for subsequent analysis like univariate statistics:

t.rast.univar input=lakes_h

Space-time Data Extracting

Raster space-time data can be extract into new datasets using t.rast.extract. In the example below three new datasets are created for the first, second and third six hours of flooding.

t.rast.extract input=lakes where="start_time > 0 and start_time < 361" output=lakes_1
t.rast.extract input=lakes where="start_time > 360 and start_time < 720" output=lakes_2
t.rast.extract input=lakes where="start_time > 720" output=lakes_3

Aggregation into single raster output can be performed by t.rast.series:

t.rast.series input=lakes_1 output=lakes_1_avg method=average

Let’s print univariate statistics for generated raster output by r.univar:

r.univar map=lakes_1_avg
minimum: 0.00152588
maximum: 2.93515
range: 2.93362
mean: 1.0993

Space-time Data Visualization

Time series can be visualized by specialized tool g.gui.timeline. Example below.

g.gui.timeline inputs=lakes_1,lakes_2,lakes_3

Fig. 101 Timeline tool showing three space-time datasets.

And finally, a simple animation can be created by g.gui.animation (File ‣ Animation tool), see Fig. 102.

g.gui.animation strds=lakes

Fig. 102 Example of flooding animation.