t.rast.what1grass
Sample a space time raster dataset at specific vector point coordinates and write the output to stdout using different layouts
Usage
t.rast.what
t.rast.what --help
t.rast.what [-niv]
[points=name]
[coordinates=east,north]
strds=name
[output=name]
[where=sql_query]
[null_value=string]
[separator=character]
[order=string
[,string, ...]]
[layout=string]
[nprocs=integer]
[--overwrite]
[--help]
[--verbose]
[--quiet]
[--ui]
Keywords
temporal, sampling, raster, time
Overview
t.rast.what is designed to sample space time raster datasets at specific point coordinates using r.what internally. The output of r.what is transformed to different output layouts. The output layouts can be specified using the layout option.
Three layouts can be specified:
- •
-
row - Row order, one vector sample point value per row
- •
-
col - Column order, create a column for each vector sample point of a single time step/raster layer
- •
-
timerow - Time order, create a column for each time step, this order is the original r.what output, except that the column names are the timestamps
Please have a look at the example to see the supported layouts.
This module is designed to run several instances of r.what to sample subsets of a space time raster dataset in parallel. Several intermediate text files will be created that are merged into a single file at the end of the processing.
Coordinates can be provided as vector map using the points option or as comma separated coordinate list with the coordinates option.
An output file can be specified using the output option. Stdout will be used if no output is specified or if the output option is set to "-".
Examples
Data preparation
In the following examples we sample a space time raster dataset that contains 4 raster map layers. First we create the STRDS that will be sampled with t.rast.what.
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10# Generate datar.mapcalc expression="a_1 = 1" -sr.mapcalc expression="a_2 = 2" -sr.mapcalc expression="a_3 = 3" -sr.mapcalc expression="a_4 = 4" -st.create type=strds output=A title="A test" descr="A test"t.register -i type=raster input=A maps=a_1,a_2,a_3,a_4 \start=’1990-01-01’ increment="1 month"
Example 1
The first approach uses text coordinates as input and stdout as output, the layout is one coordinate(point per column:
t.rast.what strds=A coordinates="115,36,79,45" layout=col -nstart|end|115.0000000000;36.0000000000|79.0000000000;45.00000000001990-01-01 00:00:00|1990-02-01 00:00:00|1|11990-02-01 00:00:00|1990-03-01 00:00:00|2|21990-03-01 00:00:00|1990-04-01 00:00:00|3|31990-04-01 00:00:00|1990-05-01 00:00:00|4|4
Example 2
A vector map layer can be used as input to sample the STRDS. All three available layouts are demonstrated using the vector map for sampling.
# First create the vector map layer based on random pointsv.random output=points n=3 seed=1# Row layout using a text file as outputt.rast.what strds=A points=points output=result.txt layout=row -ncat result.txt115.0043586274|36.3593955783|1990-01-01 00:00:00|1990-02-01 00:00:00|1115.0043586274|36.3593955783|1990-02-01 00:00:00|1990-03-01 00:00:00|2115.0043586274|36.3593955783|1990-03-01 00:00:00|1990-04-01 00:00:00|3115.0043586274|36.3593955783|1990-04-01 00:00:00|1990-05-01 00:00:00|479.6816763826|45.2391522853|1990-01-01 00:00:00|1990-02-01 00:00:00|179.6816763826|45.2391522853|1990-02-01 00:00:00|1990-03-01 00:00:00|279.6816763826|45.2391522853|1990-03-01 00:00:00|1990-04-01 00:00:00|379.6816763826|45.2391522853|1990-04-01 00:00:00|1990-05-01 00:00:00|497.4892579600|79.2347263950|1990-01-01 00:00:00|1990-02-01 00:00:00|197.4892579600|79.2347263950|1990-02-01 00:00:00|1990-03-01 00:00:00|297.4892579600|79.2347263950|1990-03-01 00:00:00|1990-04-01 00:00:00|397.4892579600|79.2347263950|1990-04-01 00:00:00|1990-05-01 00:00:00|4# Column layout order using stdout as outputt.rast.what strds=A points=points layout=col -nstart|end|115.0043586274;36.3593955783|79.6816763826;45.2391522853|97.4892579600;79.23472639501990-01-01 00:00:00|1990-02-01 00:00:00|1|1|11990-02-01 00:00:00|1990-03-01 00:00:00|2|2|21990-03-01 00:00:00|1990-04-01 00:00:00|3|3|31990-04-01 00:00:00|1990-05-01 00:00:00|4|4|4# Timerow layout, one time series per row# using the where statement to select a subset of the STRDS# and stdout as outputt.rast.what strds=A points=points \where="start_time >= ’1990-03-01’" layout=timerow -nx|y|1990-03-01 00:00:00;1990-04-01 00:00:00|1990-04-01 00:00:00;1990-05-01 00:00:00115.004358627375|36.3593955782903|3|479.681676382576|45.2391522852909|3|497.4892579600048|79.2347263950131|3|4
Source code
Available at: t.rast.what source code (history)
Accessed: Monday Feb 24 17:51:47 2025
Main index | Temporal index | Topics index | Keywords index | Graphical index | Full index
© 2003-2025 GRASS Development Team, GRASS GIS 8.4.1 Reference Manual
Releases
5 releases since Debian 9 (Stretch); the text changed 4 times.