~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to temporal/t.select/t.select.html

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<h2>DESCRIPTION</h2>
 
2
 
 
3
<em>t.select</em> performs selection of maps that are registered in 
 
4
space time datasets using temporal algebra.
 
5
 
 
6
<h3>PROGRAM USE</h3>
 
7
The module expects an <b>expression</b> as input parameter in the following form:
 
8
<p>
 
9
<tt>"result = expression"</tt>
 
10
<p>
 
11
 
 
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.
 
16
 
 
17
These expression can be any valid or nested combination of temporal 
 
18
operations and functions that are provided by the temporal algebra.  
 
19
<br>
 
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.
 
31
<p>
 
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).
 
35
<p>
 
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.
 
39
<p>
 
40
The expression option must be passed as <b>quoted</b>
 
41
expression, for example: <br>
 
42
 
 
43
<div class="code"><pre>
 
44
t.select expression="C = A : B"
 
45
</pre></div>
 
46
 
 
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.
 
50
 
 
51
<h2>TEMPORAL ALGEBRA</h2>
 
52
 
 
53
The temporal algebra provides a wide range of temporal operators and
 
54
functions that will be presented in the following section.
 
55
 
 
56
<h3>TEMPORAL RELATIONS</h3>
 
57
 
 
58
Several temporal topology relations between registered maps of space
 
59
time datasets are supported: <br>
 
60
 
 
61
<div class="code"><pre>
 
62
equals            A ------
 
63
                  B ------
 
64
 
 
65
during            A  ----
 
66
                  B ------
 
67
 
 
68
contains          A ------
 
69
                  B  ----
 
70
 
 
71
starts            A ----
 
72
                  B ------
 
73
 
 
74
started           A ------
 
75
                  B ----
 
76
 
 
77
finishs           A   ----
 
78
                  B ------
 
79
 
 
80
finished          A ------
 
81
                  B   ----
 
82
 
 
83
precedes          A ----
 
84
                  B     ----
 
85
 
 
86
follows           A     ----
 
87
                  B ----
 
88
 
 
89
overlapped        A   ------
 
90
                  B ------
 
91
 
 
92
overlaps          A ------
 
93
                  B   ------
 
94
 
 
95
over              booth overlaps and overlapped
 
96
</pre></div>
 
97
 
 
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>
 
101
 
 
102
<h3>TEMPORAL OPERATORS</h3>
 
103
 
 
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
 
112
UNION              u       Union
 
113
RIGHT REFERENCE    r       Use the time stamp of the right space time dataset
 
114
</pre></div>
 
115
 
 
116
 
 
117
<h3>TEMPORAL SELECTION</h3>
 
118
 
 
119
The temporal selection simply selects parts of a space time dataset without
 
120
processing raster or vector data.
 
121
 
 
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
 
125
 
 
126
<div class="code"><pre>
 
127
C = A : B
 
128
</pre></div>
 
129
 
 
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
 
134
 
 
135
<div class="code"><pre>
 
136
C = A !: B
 
137
</pre></div>
 
138
 
 
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"}
 
148
</pre></div>
 
149
 
 
150
Examples:
 
151
<div class="code"><pre>
 
152
C = A {:, equals} B
 
153
C = A {!:, equals} B
 
154
</pre></div>
 
155
 
 
156
We can now define arbitrary topological relations using the OR operator "|"
 
157
to connect them:
 
158
 
 
159
<div class="code"><pre>
 
160
C = A {:,equals|during|overlaps} B
 
161
</pre></div>
 
162
 
 
163
Select all parts of A that are equal to B, during B or overlaps B. <br>
 
164
 
 
165
In addition we can define the temporal extent of the result STDS by adding the
 
166
temporal operator.
 
167
 
 
168
<div class="code"><pre>
 
169
C = A {:, during,r} B
 
170
</pre></div>
 
171
 
 
172
Select all parts of A that are during B and use the temporal extents from B for 
 
173
C. <br>
 
174
 
 
175
<br>
 
176
The selection operator is implicitly contained in the temporal topology
 
177
selection operator, so that the following statements are exactly the same:
 
178
 
 
179
<div class="code"><pre>
 
180
C = A : B
 
181
C = A {:} B
 
182
C = A {:,equal} B
 
183
C = A {:,equal,l} B
 
184
</pre></div>
 
185
 
 
186
Same for the complementary selection:
 
187
<div class="code"><pre>
 
188
C = A !: B
 
189
C = A {!:} B
 
190
C = A {!:,equal} B
 
191
C = A {!:,equal,l} B
 
192
</pre></div>
 
193
 
 
194
<h3>CONDITIONAL STATEMENTS</h3>
 
195
 
 
196
Selection operations can be evaluated within conditional statements.
 
197
<br>
 
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.
 
203
 
 
204
if statement                           decision option                        temporal relations
 
205
  if(if, then, else)
 
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.
 
210
</pre></div>
 
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. 
 
215
 
 
216
<h4>Logical operators</h4>
 
217
<div class="code"><pre>
 
218
Symbol  description
 
219
 
 
220
  ==    equal
 
221
  !=    not equal
 
222
  >     greater than
 
223
  >=    greater than or equal
 
224
  <     less than
 
225
  <=    less than or equal
 
226
  &&    and
 
227
  ||    or
 
228
</pre></div>
 
229
 
 
230
<h4>Temporal functions</h4>
 
231
 
 
232
The following temporal function are evaluated only for the STDS that must
 
233
be given in parenthesis.
 
234
 
 
235
<div class="code"><pre>
 
236
td(A)                    Returns a list of time intervals of STDS A
 
237
 
 
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
 
244
 
 
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]
 
263
</pre></div>
 
264
 
 
265
<h4>Comparison operator</h4>
 
266
 
 
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 
 
270
the related maps.
 
271
For complex relations the comparison operator can be used to combine conditions: 
 
272
<br>
 
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"}
 
275
<br>
 
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>
 
284
|| -> | and && -> & 
 
285
</pre></div>
 
286
Examples:
 
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
 
293
</pre></div>
 
294
 
 
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>
 
299
A{#, contains}B
 
300
</pre></div>
 
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)
 
308
</pre></div>
 
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.
 
314
<p>
 
315
Furthermore the temporal algebra allows temporal buffering, shifting
 
316
and snapping with the functions buff_t(), tshift() and tsnap()
 
317
respectively.
 
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
 
322
</pre></div>
 
323
<br>
 
324
<h4>Single map with temporal extent</h4>
 
325
The temporal algebra can also handle single maps with time stamps in the
 
326
map function.
 
327
<div class="code"><pre>
 
328
tmap()
 
329
</pre></div>
 
330
For example:
 
331
<div class="code"><pre>
 
332
 C = A {:,during} tmap(event)
 
333
</pre></div>
 
334
This statement select all maps from space time data set A that are during
 
335
the temporal extent of single map 'event'
 
336
 
 
337
<br>
 
338
<h2>Examples</h2>
 
339
 
 
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)
 
345
</pre></div>
 
346
 
 
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)
 
352
</pre></div>
 
353
 
 
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)
 
359
</pre></div>
 
360
 
 
361
<h2>SEE ALSO</h2>
 
362
 
 
363
<em>
 
364
<a href="r.mapcalc.html">r.mapcalc</a>
 
365
</em>
 
366
 
 
367
<h2>REFERENCES</h2>
 
368
 
 
369
<a href="http://www.dabeaz.com/ply/">PLY(Python-Lex-Yacc)</a>
 
370
 
 
371
<h2>AUTHORS</h2>
 
372
 
 
373
Thomas Leppelt, S&ouml;ren Gebbert, Th&uuml;nen Institute of Climate-Smart Agriculture
 
374
 
 
375
<p><i>Last changed: $Date: 2015-01-25 18:56:33 +0100 (Sun, 25 Jan 2015) $</i>
 
376