-
-
Notifications
You must be signed in to change notification settings - Fork 283
/
t.vect.algebra.html
462 lines (349 loc) · 15.5 KB
/
t.vect.algebra.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
<h2>DESCRIPTION</h2>
<em>t.vect.algebra</em> performs temporal and spatial overlay and
buffer functions on space time vector datasets (STVDS) by using the
temporal vector algebra. New STVDS can be created, which are
expressions of existing STVDS.
<h3>PROGRAM USE</h3>
The module expects an <b>expression</b> as input parameter in the following form:
<p>
<div class="code"><pre>
"result = expression"
</pre></div>
The statement structure is similar to r.mapcalc, see <a href="r.mapcalc.html">r.mapcalc</a>.
Where <b>result</b> represents the name of a space time dataset (STVDS) that will
contain the result of the calculation that is given as <b>expression</b>
on the right side of the equality sign.
These expression can be any valid or nested combination of temporal
operations and functions that are provided by the temporal vector
algebra.<br>
The algebra provides methods for map selection from STDS based on their
temporal relations. It is also possible to temporally shift maps, to
create temporal buffer and to snap time instances to create a valid
temporal topology. Furthermore expressions can be nested and evaluated
in conditional statements (if, else statements). Within if-statements
the algebra provides temporal variables like start time, end time, day
of year, time differences or number of maps per time interval to build
up conditions. These operations can be assigned to space time datasets
or to the results of operations between space time datasets.
<p> As default, topological relationships between space time datasets
will be evaluated only temporal. Use the <b>s</b> flag to activate the
additionally spatial topology evaluation. <p> The expression option
must be passed as <b>quoted</b> expression, for example: <br>
<div class="code"><pre>
t.select expression="C = A : B"
</pre></div>
Where <b>C</b> is the new space time raster dataset that will contain
maps from <b>A</b> that are selected by equal temporal relationships to
the existing dataset <b>B</b> in this case.
<h2>TEMPORAL VECTOR ALGEBRA</h2>
The temporal algebra provides a wide range of temporal operators and
functions that will be presented in the following section. <p>
<h3>TEMPORAL RELATIONS</h3>
Several temporal topology relations between registered maps of space
time datasets are supported: <br>
<div class="code"><pre>
equals A ------
B ------
during A ----
B ------
contains A ------
B ----
starts A ----
B ------
started A ------
B ----
finishs A ----
B ------
finished A ------
B ----
precedes A ----
B ----
follows A ----
B ----
overlapped A ------
B ------
overlaps A ------
B ------
over booth overlaps and overlapped
</pre></div>
The relations must be read as: A is related to B, like - A equals B - A is
during B - A contains B <p>
Topological relations must be specified in {} parentheses. <br>
<h3>TEMPORAL OPERATORS</h3>
The temporal algebra defines temporal operators that can be combined
with other operators to perform spatio-temporal operations. The
temporal operators process the time instances and intervals of two
temporal related maps and calculate the result temporal extent by five
different possibilities.
<div class="code"><pre>
LEFT REFERENCE l Use the time stamp of the left space time dataset
INTERSECTION i Intersection
DISJOINT UNION d Disjoint union
UNION u Union
RIGHT REFERENCE r Use the time stamp of the right space time dataset
</pre></div>
<h3>TEMPORAL SELECTION</h3>
The temporal selection simply selects parts of a space time dataset without
processing raster or vector data.
The algebra provides a selection operator <b>:</b> that selects parts
of a space time dataset that are temporally equal to parts of a second one
by default. The following expression
<div class="code"><pre>
C = A : B
</pre></div>
means: Select all parts of space time dataset A that are equal to B and
store it in space time dataset C. The parts are time stamped maps.
<p>
In addition the inverse selection operator <b>!:</b> is defined as
the complement of the selection operator, hence the following
expression
<div class="code"><pre>
C = A !: B
</pre></div>
means: select all parts of space time time dataset A that are not equal to B
and store it in space time dataset (STDS) C.<p>
To select parts of a STDS by different topological relations to other
STDS, the temporal topology selection operator can be used. The
operator consists of the temporal selection operator, the topological
relations, that must be separated by the logical OR operator <b>|</b>
and the temporal extent operator. All three parts are separated by
comma and surrounded by curly braces:
<div class="code"><pre>
{"temporal selection operator", "topological relations", "temporal operator"}
</pre></div>
<p>
Examples:
<div class="code"><pre>
C = A {:, equals} B
C = A {!:, equals} B
</pre></div>
We can now define arbitrary topological relations using the OR operator "|"
to connect them:
<div class="code"><pre>
C = A {:,equals|during|overlaps} B
</pre></div>
Select all parts of A that are equal to B, during B or overlaps B. <br>
In addition we can define the temporal extent of the result STDS by adding the
temporal operator.
<div class="code"><pre>
C = A {:, during,r} B
</pre></div>
Select all parts of A that are during B and use the temporal extents
from B for C.
<p>
The selection operator is implicitly contained in the temporal topology
selection operator, so that the following statements are exactly the same:
<div class="code"><pre>
C = A : B
C = A {:} B
C = A {:,equal} B
C = A {:,equal,l} B
</pre></div>
Same for the complementary selection:
<div class="code"><pre>
C = A !: B
C = A {!:} B
C = A {!:,equal} B
C = A {!:,equal,l} B
</pre></div>
<h3>CONDITIONAL STATEMENTS</h3>
Selection operations can be evaluated within conditional statements.
<br>
Note A and B can either be space time datasets or expressions. The temporal
relationship between the conditions and the conclusions can be defined at the
beginning of the if statement. The relationship between then and else conclusion
must be always equal.
<div class="code"><pre>
if statement decision option temporal relations
if(if, then, else)
if(conditions, A) A if conditions are True; temporal topological relation between if and then is equal.
if(conditions, A, B) A if conditions are True, B otherwise; temporal topological relation between if, then and else is equal.
if(topologies, conditions, A) A if conditions are True; temporal topological relation between if and then is explicit specified by topologies.
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.
</pre></div>
<h4>Logical operators</h4>
<div class="code"><pre>
Symbol description
== equal
!= not equal
> greater than
>= greater than or equal
< less than
<= less than or equal
&& and
|| or
</pre></div>
<h4>Temporal functions</h4>
The following temporal function are evaluated only for the STDS that
must be given in parenthesis.
<div class="code"><pre>
td(A) Returns a list of time intervals of STDS A
start_time(A) Start time as HH::MM:SS
start_date(A) Start date as yyyy-mm-DD
start_datetime(A) Start datetime as yyyy-mm-DD HH:MM:SS
end_time(A) End time as HH:MM:SS
end_date(A) End date as yyyy-mm-DD
end_datetime(A) End datetime as yyyy-mm-DD HH:MM
start_doy(A) Day of year (doy) from the start time [1 - 366]
start_dow(A) Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1
start_year(A) The year of the start time [0 - 9999]
start_month(A) The month of the start time [1 - 12]
start_week(A) Week of year of the start time [1 - 54]
start_day(A) Day of month from the start time [1 - 31]
start_hour(A) The hour of the start time [0 - 23]
start_minute(A) The minute of the start time [0 - 59]
start_second(A) The second of the start time [0 - 59]
end_doy(A) Day of year (doy) from the end time [1 - 366]
end_dow(A) Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1
end_year(A) The year of the end time [0 - 9999]
end_month(A) The month of the end time [1 - 12]
end_week(A) Week of year of the end time [1 - 54]
end_day(A) Day of month from the start time [1 - 31]
end_hour(A) The hour of the end time [0 - 23]
end_minute(A) The minute of the end time [0 - 59]
end_second(A) The second of the end time [0 - 59]
</pre></div>
<h4>Comparison operator</h4>
The conditions are comparison expressions that are used to evaluate
space time datasets. Specific values of temporal variables are
compared by logical operators and evaluated for each map of the STDS and
the related maps.
For complex relations the comparison operator can be used to combine conditions:
<br>
The structure is similar to the select operator with the extension of an aggregation operator:
<div class="code"><pre>
{"comparison operator", "topological relations", aggregation operator, "temporal operator"}
</pre></div>
<br>
This aggregation operator (| or &) define the behaviour if a map is related the more
than one map, e.g for the topological relations 'contains'.
Should all (&) conditions for the related maps be true or is it sufficient to
have any (|) condition that is true. The resulting boolean value is then compared
to the first condition by the comparison operator (|| or &&).
As default the aggregation operator is related to the comparison operator: <br>
Comparison operator -> aggregation operator:
<div class="code"><pre>
|| -> | and && -> &
</pre></div>
Examples:
<div class="code"><pre>
Condition 1 {||, equal, r} Condition 2
Condition 1 {&&, equal|during, l} Condition 2
Condition 1 {&&, equal|contains, |, l} Condition 2
Condition 1 {&&, equal|during, l} Condition 2 && Condition 3
Condition 1 {&&, equal|during, l} Condition 2 {&&,contains, |, r} Condition 3
</pre></div>
<h4>Hash operator</h4>
Additionally the number of maps in intervals can be computed and used in
conditional statements with the hash (#) operator. <br>
<div class="code"><pre>
A{#, contains}B
</pre></div>
This expression computes the number of maps from space
time dataset B which are during the time intervals of maps from
space time dataset A.<br>
A list of integers (scalars) corresponding to the maps of A
that contain maps from B will be returned.
<p>
<div class="code"><pre>
C = if({equal}, A {#, contains} B > 2, A {:, contains} B)
</pre></div>
This expression selects all maps from A that temporally contains at least 2
maps from B and stores them in space time dataset C. The leading equal statement
in the if condition specifies the temporal relation between the if and then part
of the if expression. This is very important, so we do not need to specify a
global time reference (a space time dataset) for temporal processing.
<p>
Furthermore the temporal algebra allows temporal buffering, shifting
and snapping with the functions buff_t(), tshift() and tsnap()
respectively.
<div class="code"><pre>
buff_t(A, size) Buffer STDS A with granule ("1 month" or 5)
tshift(A, size) Shift STDS A with granule ("1 month" or 5)
tsnap(A) Snap time instances and intervals of STDS A
</pre></div>
<h4>Single map with temporal extent</h4>
The temporal algebra can also handle single maps with time stamps in
the tmap function.
<div class="code"><pre>
tmap()
</pre></div>
For example:
<div class="code"><pre>
C = A {:,during} tmap(event)
</pre></div>
This statement select all maps from space time data set A that are
during the temporal extent of single map 'event'
<h3>Spatial vector operators</h3>
The module supports the following boolean vector operations:<br>
<div class="code"><pre>
Boolean Name Operator Meaning Precedence Correspondent function
----------------------------------------------------------------------------------
AND & Intersection 1 (v.overlay operator=and)
OR | Union 1 (v.overlay operator=or)
DISJOINT OR + Disjoint union 1 (v.patch)
XOR ^ Symmetric difference 1 (v.overlay operator=xor)
NOT ~ Complement 1 (v.overlay operator=not)
</pre></div>
And vector functions:
<div class="code"><pre>
buff_p(A, size) Buffer the points of vector map layer A with size
buff_l(A, size) Buffer the lines of vector map layer A with size
buff_a(A, size) Buffer the areas of vector map layer A with size
</pre></div>
<h3>Combinations of temporal, vector and select operators</h3>
We combine the temporal topology relations, the temporal operators and
the spatial/select operators to create spatio-temporal vector
operators:
<pre class="code">
{"spatial or select operator" , "list of temporal relations", "temporal operator" }
</pre><p>
For multiple topological relations or several related maps the spatio-temporal
operators feature implicit aggregation.
The algebra evaluates the stated STDS by their temporal topologies and apply
the given spatio temporal operators in a aggregated form.
If we have two STDS A and B, B has three maps: b1, b2, b3 that are all during
the temporal extent of the single map a1 of A, then the following overlay
calculations would implicitly aggregate all maps of B into one result map for
a1 of A:
<div class="code"><pre>
C = A {&, contains} B --> c1 = a1 & b1 & b2 & b3
</pre></div>
Keep attention that the aggregation behaviour is not symmetric:
<div class="code"><pre>
C = B {&, during} A --> c1 = b1 & a1
c2 = b2 & a1
c3 = b3 & a1
</pre></div>
<h3>Examples: </h3>
Spatio-temporal intersect all maps from space time dataset A with all
maps from space time dataset B which have equal time stamps and are
temporary before Jan. 1. 2005 and store them in space time dataset D.
<div class="code"><pre>
D = if(start_date(A) < "2005-01-01", A & B)
</pre></div>
Buffer all vector points from space time vector dataset A and B with a
distance of one and intersect the results with overlapping, containing,
during and equal temporal relations to store the result in space time
vector dataset D with intersected time stamps.
<div class="code"><pre>
D = buff_p(A, 1) {&,overlaps|overlapped|equal|during|contains,i} buff_p(B, 1)
</pre></div>
Select all maps from space time dataset B which are during the temporal
buffered space time dataset A with a map interval of three days, else
select maps from C and store them in space time dataset D.
<div class="code"><pre>
D = if(contains, td(buff_t(A, "1 days")) == 3, B, C)
</pre></div>
<h2>REFERENCES</h2>
<a href="http://www.dabeaz.com/ply/">PLY(Python-Lex-Yacc)</a>
<h2>SEE ALSO</h2>
<em>
<a href="t.select.html">t.select</a>
</em>
<h2>AUTHORS</h2>
Thomas Leppelt, Soeren Gebbert, Thünen Institute of Climate-Smart Agriculture
<!--
<p>
<i>Last changed: $Date$</i>
-->