3
<em>t.select</em> performs selection of maps that are registered in
4
space time datasets using temporal algebra.
7
The module expects an <b>expression</b> as input parameter in the following form:
9
<tt>"result = expression"</tt>
12
The statement structure is similar to r.mapcalc, see <a href="r.mapcalc.html">r.mapcalc</a>.
13
Where <b>result</b> represents the name of a space time dataset
14
(STDS)that will contain the result of the calculation that is given as
15
<b>expression</b> on the right side of the equality sign.
17
These expression can be any valid or nested combination of temporal
18
operations and functions that are provided by the temporal algebra.
20
The temporal algebra works with space time datasets of any type
21
(STRDS, STR3DS and STVDS). The algebra provides methods for map
22
selection from STDS based on their temporal relations. It is also
23
possible to temporally shift maps, to create temporal buffer and to
24
snap time instances to create a valid temporal topology. Furthermore
25
expressions can be nested and evaluated in conditional statements (if,
26
else statements). Within if-statements the algebra provides temporal
27
variables like start time, end time, day of year, time differences or
28
number of maps per time interval to build up conditions. These
29
operations can be assigned to space time datasets or to the results of
30
operations between space time datasets.
32
The type of the input space time datasets must be defined with the input
33
parameter <b>type</b>. Possible options are STRDS, STVDS or STR3DS.
34
The default is set to space time raster datasets (STRDS).
36
As default, topological relationships between space time datasets will be
37
evaluated only temporal. Use the <b>s</b> flag to activate the
38
additionally spatial topology evaluation.
40
The expression option must be passed as <b>quoted</b>
41
expression, for example: <br>
43
<div class="code"><pre>
44
t.select expression="C = A : B"
47
Where <b>C</b> is the new space time raster dataset that will contain maps
48
from <b>A</b> that are selected by equal temporal relationships
49
to the existing dataset <b>B</b> in this case.
51
<h2>TEMPORAL ALGEBRA</h2>
53
The temporal algebra provides a wide range of temporal operators and
54
functions that will be presented in the following section.
56
<h3>TEMPORAL RELATIONS</h3>
58
Several temporal topology relations between registered maps of space
59
time datasets are supported: <br>
61
<div class="code"><pre>
95
over booth overlaps and overlapped
98
The relations must be read as: A is related to B, like - A equals B - A is
99
during B - A contains B <p>
100
Topological relations must be specified in {} parentheses. <br>
102
<h3>TEMPORAL OPERATORS</h3>
104
The temporal algebra defines temporal operators that can be combined with other
105
operators to perform spatio-temporal operations.
106
The temporal operators process the time instances and intervals of two temporal
107
related maps and calculate the result temporal extent by five differnt possibilities.
108
<div class="code"><pre>
109
LEFT REFERENCE l Use the time stamp of the left space time dataset
110
INTERSECTION i Intersection
111
DISJOINT UNION d Disjoint union
113
RIGHT REFERENCE r Use the time stamp of the right space time dataset
117
<h3>TEMPORAL SELECTION</h3>
119
The temporal selection simply selects parts of a space time dataset without
120
processing raster or vector data.
122
The algebra provides a selection operator <b>:</b> that selects parts
123
of a space time dataset that are temporally equal to parts of a second one
124
by default. The following expression
126
<div class="code"><pre>
130
means: Select all parts of space time dataset A that are equal to B and store
131
it in space time dataset C. The parts are time stamped maps. <p>
132
In addition the inverse selection operator <b>!:</b> is defined as the
133
complement of the selection operator, hence the following expression
135
<div class="code"><pre>
139
means: select all parts of space time time dataset A that are not equal to B
140
and store it in space time dataset (STDS) C. <p>
141
To select parts of a STDS by different topological relations to other STDS,
142
the temporal topology selection operator can be used. The operator consists of
143
the temporal selection operator, the topological relations, that must be separated
144
by the logical OR operator <b>|</b> and the temporal extent operator.
145
All three parts are separated by comma and surrounded by curly braces:
146
<div class="code"><pre>
147
{"temporal selection operator", "topological relations", "temporal operator"}
151
<div class="code"><pre>
156
We can now define arbitrary topological relations using the OR operator "|"
159
<div class="code"><pre>
160
C = A {:,equals|during|overlaps} B
163
Select all parts of A that are equal to B, during B or overlaps B. <br>
165
In addition we can define the temporal extent of the result STDS by adding the
168
<div class="code"><pre>
169
C = A {:, during,r} B
172
Select all parts of A that are during B and use the temporal extents from B for
176
The selection operator is implicitly contained in the temporal topology
177
selection operator, so that the following statements are exactly the same:
179
<div class="code"><pre>
186
Same for the complementary selection:
187
<div class="code"><pre>
194
<h3>CONDITIONAL STATEMENTS</h3>
196
Selection operations can be evaluated within conditional statements.
198
<div class="code"><pre>
199
Note A and B can either be space time datasets or expressions. The temporal
200
relationship between the conditions and the conclusions can be defined at the
201
beginning of the if statement. The relationship between then and else conclusion
202
must be always equal.
204
if statement decision option temporal relations
206
if(conditions, A) A if conditions are True; temporal topological relation between if and then is equal.
207
if(conditions, A, B) A if conditions are True, B otherwise; temporal topological relation between if, then and else is equal.
208
if(topologies, conditions, A) A if conditions are True; temporal topological relation between if and then is explicit specified by topologies.
209
if(topologies, conditions, A, B) A if conditions are True, B otherwise; temporal topological relation between if, then and else is explicit specified by topologies.
211
The conditions are comparison expressions that are used to evaluate
212
space time datasets. Specific values of temporal variables are
213
compared by logical operators and evaluated for each map of the STDS.<br>
214
<b>Important:</b> The conditions are evaluated from left to right.
216
<h4>Logical operators</h4>
217
<div class="code"><pre>
223
>= greater than or equal
225
<= less than or equal
230
<h4>Temporal functions</h4>
232
The following temporal function are evaluated only for the STDS that must
233
be given in parenthesis.
235
<div class="code"><pre>
236
td(A) Returns a list of time intervals of STDS A
238
start_time(A) Start time as HH::MM:SS
239
start_date(A) Start date as yyyy-mm-DD
240
start_datetime(A) Start datetime as yyyy-mm-DD HH:MM:SS
241
end_time(A) End time as HH:MM:SS
242
end_date(A) End date as yyyy-mm-DD
243
end_datetime(A) End datetime as yyyy-mm-DD HH:MM
245
start_doy(A) Day of year (doy) from the start time [1 - 366]
246
start_dow(A) Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1
247
start_year(A) The year of the start time [0 - 9999]
248
start_month(A) The month of the start time [1 - 12]
249
start_week(A) Week of year of the start time [1 - 54]
250
start_day(A) Day of month from the start time [1 - 31]
251
start_hour(A) The hour of the start time [0 - 23]
252
start_minute(A) The minute of the start time [0 - 59]
253
start_second(A) The second of the start time [0 - 59]
254
end_doy(A) Day of year (doy) from the end time [1 - 366]
255
end_dow(A) Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1
256
end_year(A) The year of the end time [0 - 9999]
257
end_month(A) The month of the end time [1 - 12]
258
end_week(A) Week of year of the end time [1 - 54]
259
end_day(A) Day of month from the start time [1 - 31]
260
end_hour(A) The hour of the end time [0 - 23]
261
end_minute(A) The minute of the end time [0 - 59]
262
end_second(A) The second of the end time [0 - 59]
265
<h4>Comparison operator</h4>
267
The conditions are comparison expressions that are used to evaluate
268
space time datasets. Specific values of temporal variables are
269
compared by logical operators and evaluated for each map of the STDS and
271
For complex relations the comparison operator can be used to combine conditions:
273
The structure is similar to the select operator with the extension of an aggregation operator:
274
{"comparison operator", "topological relations", aggregation operator, "temporal operator"}
276
This aggregation operator (| or &) define the behaviour if a map is related the more
277
than one map, e.g for the topological relations 'contains'.
278
Should all (&) conditions for the related maps be true or is it sufficient to
279
have any (|) condition that is true. The resulting boolean value is then compared
280
to the first condition by the comparison operator (|| or &&).
281
As default the aggregation operator is related to the comparison operator: <br>
282
Comparison operator -> aggregation operator:
283
<div class="code"><pre>
287
<div class="code"><pre>
288
Condition 1 {||, equal, r} Condition 2
289
Condition 1 {&&, equal|during, l} Condition 2
290
Condition 1 {&&, equal|contains, |, l} Condition 2
291
Condition 1 {&&, equal|during, l} Condition 2 && Condition 3
292
Condition 1 {&&, equal|during, l} Condition 2 {&&,contains, |, r} Condition 3
295
<h4>Hash operator</h4>
296
Additionally the number of maps in intervals can be computed and used in
297
conditional statements with the hash (#) operator. <br>
298
<div class="code"><pre>
301
This expression computes the number of maps from space
302
time dataset B which are during the time intervals of maps from
303
space time dataset A.<br>
304
A list of integers (scalars) corresponding to the maps of A
305
that contain maps from B will be returned. <p>
306
<div class="code"><pre>
307
C = if({equal}, A {#, contains} B > 2, A {:, contains} B)
309
This expression selects all maps from A that temporally contains at least 2
310
maps from B and stores them in space time dataset C. The leading equal statement
311
in the if condition specifies the temporal relation between the if and then part
312
of the if expression. This is very important, so we do not need to specify a
313
global time reference (a space time dataset) for temporal processing.
315
Furthermore the temporal algebra allows temporal buffering, shifting
316
and snapping with the functions buff_t(), tshift() and tsnap()
318
<div class="code"><pre>
319
buff_t(A, size) Buffer STDS A with granule ("1 month" or 5)
320
tshift(A, size) Shift STDS A with granule ("1 month" or 5)
321
tsnap(A) Snap time instances and intervals of STDS A
324
<h4>Single map with temporal extent</h4>
325
The temporal algebra can also handle single maps with time stamps in the
327
<div class="code"><pre>
331
<div class="code"><pre>
332
C = A {:,during} tmap(event)
334
This statement select all maps from space time data set A that are during
335
the temporal extent of single map 'event'
340
Select all maps from space time dataset A which have equal time stamps
341
with space time dataset B and C and are ealier that Jan. 1. 2005 and
342
store them in space time dataset D.
343
<div class="code"><pre>
344
D = if(start_date(A) < "2005-01-01", A : B : C)
347
Select all maps from space time dataset A which contains more than three
348
maps of space time dataset B, else select maps from C with time
349
stamps that are not equal to A and store them in space time dataset D.
350
<div class="code"><pre>
351
D = if(A {#, contains} B > 3, A {:, contains} B, C)
354
Select all maps from space time dataset B which are during the temporal
355
buffered space time dataset A with a map interval of three days, else
356
select maps from C and store them in space time dataset D.
357
<div class="code"><pre>
358
D = if(contains, td(buff_t(A, "1 days")) == 3, B, C)
364
<a href="r.mapcalc.html">r.mapcalc</a>
369
<a href="http://www.dabeaz.com/ply/">PLY(Python-Lex-Yacc)</a>
373
Thomas Leppelt, Sören Gebbert, Thünen Institute of Climate-Smart Agriculture
375
<p><i>Last changed: $Date: 2015-01-25 18:56:33 +0100 (Sun, 25 Jan 2015) $</i>