DESCRIPTION
t.vect.mapcalc 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.
PROGRAM USE
The module expects an expression as input parameter in the following form:
"result = expression"
The statement structure is similar to r.mapcalc, see r.mapcalc.
Where result represents the name of a space time vector dataset (STVDS)that will
contain the result of the calculation that is given as expression
on the right side of the equality sign.
These expression can be any valid or nested combination of temporal
operations and spatial overlay or buffer functions that are provided by the temporal algebra.
The temporal vector algebra works with space time vector datasets only (STVDS).
The algebra provides methods for map selection from STVDS 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. In addition the algebra provides
the spatial operations for vector overlay and buffering. All these operations can be assigned
to STVDS or to the resulting map lists of operations between STVDS.
As default, topological relationships between space time datasets will be
evaluated only temporal. Use the s flag to activate the
additionally evaluate the spatial topology based on the spatial extents of maps.
The expression option must be passed as quoted
expression, for example:
t.vect.mapcalc expression="C = A & B" basename=result
Where C is the new space time vector dataset that will contain maps
with the basename "result" that represent the intersection of maps from STVDS A and
equally temporal related maps from STVDS B.
The map basename for the result STVDS must always be specified.
Temporal vector algebra
The temporal vector algebra provides a wide range of temporal and spatial operators and
functions that will be presented in the following section.
Temporal relations
Several temporal topology relations between space
time datasets are supported:
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
The relations must be read as: A is related to B, like - A equals B - A is
during B - A contains B
Topological relations must be specified in {} parentheses.
Temporal Selection
The temporal selection simply selects parts of a space time dataset without
processing raster or vector data.
The algebra provides a selection operator : that selects parts
of a space time dataset that are temporally equal to parts of a second one
by default. The following expression
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.
In addition the inverse selection operator !: is defined as the complement of
the selection operator, hence the following expression
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.
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
topological relations, that must be separated by the logical OR operator
| and the temporal selection operator. Both parts are separated by
comma and surrounded by curly braces:
{"topological relations", "temporal selection operator"}
Examples:
C = A {equals,:} B
C = A {equals,!:} B
We can now define arbitrary topological relations using logical OR operator
to connect them:
C = A {equals|during|overlaps,:} B
Select all parts of A that are equal to B, during B or overlaps B.
The selection operator is implicitly contained in the temporal topology
selection operator, so that the following statements are exactly the same:
C = A : B
C = A {:} B
C = A {equal,:} B
Same for the complementary selection:
C = A !: B
C = A {!:} B
C = A {equal,!:} B
Conditional statements
Selection operations can be evaluated within conditional statements.
Note A and B can either be space time datasets or expressions.
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.
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.
The supported logical operators:
Symbol description
== equal
!= not equal
> greater than
>= greater than or equal
< less than
<= less than or equal
&& and
|| or
Temporal functions:
td(A) Returns a list of time intervals of STDS A
start_time() Start time as HH::MM:SS
start_date() Start date as yyyy-mm-DD
start_datetime() Start datetime as yyyy-mm-DD HH:MM:SS
end_time() End time as HH:MM:SS
end_date() End date as yyyy-mm-DD
end_datetime() End datetime as yyyy-mm-DD HH:MM
start_doy() Day of year (doy) from the start time [1 - 366]
start_dow() Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1
start_year() The year of the start time [0 - 9999]
start_month() The month of the start time [1 - 12]
start_week() Week of year of the start time [1 - 54]
start_day() Day of month from the start time [1 - 31]
start_hour() The hour of the start time [0 - 23]
start_minute() The minute of the start time [0 - 59]
start_second() The second of the start time [0 - 59]
end_doy() Day of year (doy) from the end time [1 - 366]
end_dow() Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1
end_year() The year of the end time [0 - 9999]
end_month() The month of the end time [1 - 12]
end_week() Week of year of the end time [1 - 54]
end_day() Day of month from the start time [1 - 31]
end_hour() The hour of the end time [0 - 23]
end_minute() The minute of the end time [0 - 59]
end_second() The second of the end time [0 - 59]
Additionally the number of maps in intervals can be computed and
used in conditional statements.
The operator to count the number of maps
is the hash #.
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.
A list of integers (scalars) corresponding to the maps of A
that contain maps from B will be returned.
Furthermore the temporal algebra allows temporal buffering, shifting
and snapping with the functions buff_t(), tshift() and tsnap()
respectively.
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
Temporal Operators
The temporal algebra defines temporal operators that can be combined
later with spatial operators to perform spatio-temporal operations.
The temporal operators process the time instances and intervals of temporal related maps.
AND & Intersection
OR | Union
DISJOINT OR + Disjoint union
LEFT REFERENCE = Use the time stamp of the left space time dataset
For example we can compute the intersection, union or disjoint union from time stamps of maps
that temporally overlap, or we can just keep the time stamp of the left STDS.
Spatial vector operators
The module supports the following boolean vector operations:
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)
And vector functions:
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
Combinations of temporal, vector and select operators
We combine the temporal topology relations, the temporal operators and the spatial/select operators to create spatio-temporal operators:
{"list of temporal relations", "temporal operator" "spatial or select operator"}
The spatial and the select operators can be used stand-alone. In this case the temporal topology relation "equal" and the temporal operator "left reference =" is assumed and used as default. This allows the convenient use of the spatial and select
operators in case of space time vector datasets with equal time stamps.
---------------------------------------
| | & | | | ^ | ~ | + | : | !: |
|---|----|----|----|----|----|----|-----|
| & | && | &| | &^ | &~ | &+ | &: | &!: |
| | | |& | || | |^ | |~ | |+ | |: | |!: |
| + | +& | +| | +^ | +~ | ++ | +: | +!: |
| = | =& | =| | =^ | =~ | =+ | =: | =!: |
---------------------------------------
Examples:
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.
D = if(start_date() < "2005-01-01", A & B)
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.
D = buff_p(A, 1) {overlaps|overlapped|equal|during|contains,&&} buff_p(B, 1)
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.
D = if(contain, td(buff_t(A, "1 days")) == 3, B, C)
REFERENCES
PLY(Python-Lex-Yacc)
SEE ALSO
t.select
AUTHOR
Thomas Leppelt, Soeren Gebbert, Thuenen Institut, Germany
Last changed: $Date$