[GRASS-SVN] r62636 - in grass/trunk/temporal: . t.vect.algebra t.vect.algebra/testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Nov 6 06:05:22 PST 2014
Author: huhabla
Date: 2014-11-06 06:05:21 -0800 (Thu, 06 Nov 2014)
New Revision: 62636
Added:
grass/trunk/temporal/t.vect.algebra/
grass/trunk/temporal/t.vect.algebra/t.vect.algebra.html
grass/trunk/temporal/t.vect.algebra/t.vect.algebra.py
grass/trunk/temporal/t.vect.algebra/testsuite/test.t.vect.algebra.sh
Removed:
grass/trunk/temporal/t.vect.algebra/t.vect.mapcalc.html
grass/trunk/temporal/t.vect.algebra/t.vect.mapcalc.py
grass/trunk/temporal/t.vect.algebra/testsuite/test.t.vect.mapcalc.sh
grass/trunk/temporal/t.vect.mapcalc/
Modified:
grass/trunk/temporal/t.vect.algebra/Makefile
Log:
temporal modules: Renaming vector mapcalc module into vector algebra module
Modified: grass/trunk/temporal/t.vect.algebra/Makefile
===================================================================
--- grass/trunk/temporal/t.vect.mapcalc/Makefile 2014-11-05 21:51:48 UTC (rev 62629)
+++ grass/trunk/temporal/t.vect.algebra/Makefile 2014-11-06 14:05:21 UTC (rev 62636)
@@ -1,6 +1,6 @@
MODULE_TOPDIR = ../../
-PGM = t.vect.mapcalc
+PGM = t.vect.algebra
include $(MODULE_TOPDIR)/include/Make/Script.make
Copied: grass/trunk/temporal/t.vect.algebra/t.vect.algebra.html (from rev 62629, grass/trunk/temporal/t.vect.mapcalc/t.vect.mapcalc.html)
===================================================================
--- grass/trunk/temporal/t.vect.algebra/t.vect.algebra.html (rev 0)
+++ grass/trunk/temporal/t.vect.algebra/t.vect.algebra.html 2014-11-06 14:05:21 UTC (rev 62636)
@@ -0,0 +1,407 @@
+<h2>DESCRIPTION</h2>
+
+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.
+
+<h3>PROGRAM USE</h3>
+The module expects an <b>expression</b> as input parameter in the following form: <br>
+<br>
+<b> "result = expression" </b>
+<br>
+<br>
+
+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.
+<br>
+<br>
+The type of the input space time datasets must be defined with the input
+parameter <b>type</b>. Possible options are STRDS, STVDS or STR3DS.
+The default is set to space time raster datasets (STRDS).
+<br>
+<br>
+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.
+<br>
+<br>
+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. <br>
+<br>
+<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. <br>
+<br>
+
+<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 <br>
+<br>
+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 differnt 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. <br>
+<br>
+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. <br>
+<br>
+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:
+{"temporal selection operator", "topological relations", "temporal operator"} <br>
+<br>
+
+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. <br>
+
+<br>
+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>
+<div class="code"><pre>
+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.
+
+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 extention of an aggregation operator:
+{"comparison operator", "topological relations", aggregation operator, "temporal operator"}
+<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. <br>
+<br>
+<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.
+<br>
+<br>
+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>
+<br>
+<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'
+
+<br>
+
+<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>
+<br>
+
+<p>
+<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:
+<pre class="code">
+C = A {&, contains} B --> c1 = a1 & b1 & b2 & b3
+</pre><p>
+Keep attention that the aggregation behaviour is not symmetric:
+<pre class="code">
+C = B {&, during} A --> c1 = b1 & a1
+ c2 = b2 & a1
+ c3 = b3 & a1
+</pre><p>
+<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>
+
+<tt><a href="http://www.dabeaz.com/ply/">PLY(Python-Lex-Yacc)</a></tt>
+
+<h2>SEE ALSO</h2>
+
+<em>
+<a href="t.select.html">t.select</a>
+</em>
+
+
+<h2>AUTHOR</h2>
+
+Thomas Leppelt, Soeren Gebbert, Thuenen Institut, Germany <br>
+
+<p><i>Last changed: $Date$</i>
+
Copied: grass/trunk/temporal/t.vect.algebra/t.vect.algebra.py (from rev 62629, grass/trunk/temporal/t.vect.mapcalc/t.vect.mapcalc.py)
===================================================================
--- grass/trunk/temporal/t.vect.algebra/t.vect.algebra.py (rev 0)
+++ grass/trunk/temporal/t.vect.algebra/t.vect.algebra.py 2014-11-06 14:05:21 UTC (rev 62636)
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+############################################################################
+#
+# MODULE: t.vect.mapcalc
+# AUTHOR(S): Thomas Leppelt, Soeren Gebbert
+#
+# PURPOSE: Provide temporal vector algebra to perform spatial an temporal operations
+# for space time datasets by topological relationships to other space time
+# datasets.
+# COPYRIGHT: (C) 2014 by the GRASS Development Team
+#
+# This program is free software under the GNU General Public
+# License (version 2). Read the file COPYING that comes with GRASS
+# for details.
+#
+#############################################################################
+
+#%module
+#% description: Apply temporal and spatial oeprations on space time vector datasets using temporal vector algebra.
+#% keywords: temporal
+#% keywords: algebra
+#%end
+
+#%option
+#% key: expression
+#% type: string
+#% description: Spatio-temporal mapcalc expression
+#% key_desc: expression
+#% required : yes
+#%end
+
+#%option
+#% key: basename
+#% type: string
+#% label: Basename of the new generated output maps
+#% description: A numerical suffix separated by an underscore will be attached to create a unique identifier
+#% key_desc: basename
+#% required : yes
+#%end
+
+#%flag
+#% key: s
+#% description: Activate spatial topology
+#%end
+
+import grass.script
+import grass.temporal as tgis
+import sys
+
+def main():
+ expression = options['expression']
+ basename = options['basename']
+ spatial = flags["s"]
+ stdstype = "stvds"
+
+ # Check for PLY istallation
+ try:
+ import ply.lex as lex
+ import ply.yacc as yacc
+ except:
+ grass.script.fatal(_("Please install PLY (Lex and Yacc Python implementation) to use the temporal algebra modules."))
+
+ tgis.init(True)
+ p = tgis.TemporalVectorAlgebraParser(run = True, debug=False, spatial = spatial)
+ p.parse(expression, basename, grass.script.overwrite())
+
+if __name__ == "__main__":
+ options, flags = grass.script.parser()
+ sys.exit(main())
+
Deleted: grass/trunk/temporal/t.vect.algebra/t.vect.mapcalc.html
===================================================================
--- grass/trunk/temporal/t.vect.mapcalc/t.vect.mapcalc.html 2014-11-05 21:51:48 UTC (rev 62629)
+++ grass/trunk/temporal/t.vect.algebra/t.vect.mapcalc.html 2014-11-06 14:05:21 UTC (rev 62636)
@@ -1,407 +0,0 @@
-<h2>DESCRIPTION</h2>
-
-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.
-
-<h3>PROGRAM USE</h3>
-The module expects an <b>expression</b> as input parameter in the following form: <br>
-<br>
-<b> "result = expression" </b>
-<br>
-<br>
-
-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.
-<br>
-<br>
-The type of the input space time datasets must be defined with the input
-parameter <b>type</b>. Possible options are STRDS, STVDS or STR3DS.
-The default is set to space time raster datasets (STRDS).
-<br>
-<br>
-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.
-<br>
-<br>
-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. <br>
-<br>
-<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. <br>
-<br>
-
-<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 <br>
-<br>
-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 differnt 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. <br>
-<br>
-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. <br>
-<br>
-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:
-{"temporal selection operator", "topological relations", "temporal operator"} <br>
-<br>
-
-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. <br>
-
-<br>
-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>
-<div class="code"><pre>
-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.
-
-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 extention of an aggregation operator:
-{"comparison operator", "topological relations", aggregation operator, "temporal operator"}
-<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. <br>
-<br>
-<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.
-<br>
-<br>
-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>
-<br>
-<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'
-
-<br>
-
-<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>
-<br>
-
-<p>
-<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:
-<pre class="code">
-C = A {&, contains} B --> c1 = a1 & b1 & b2 & b3
-</pre><p>
-Keep attention that the aggregation behaviour is not symmetric:
-<pre class="code">
-C = B {&, during} A --> c1 = b1 & a1
- c2 = b2 & a1
- c3 = b3 & a1
-</pre><p>
-<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>
-
-<tt><a href="http://www.dabeaz.com/ply/">PLY(Python-Lex-Yacc)</a></tt>
-
-<h2>SEE ALSO</h2>
-
-<em>
-<a href="t.select.html">t.select</a>
-</em>
-
-
-<h2>AUTHOR</h2>
-
-Thomas Leppelt, Soeren Gebbert, Thuenen Institut, Germany <br>
-
-<p><i>Last changed: $Date$</i>
-
Deleted: grass/trunk/temporal/t.vect.algebra/t.vect.mapcalc.py
===================================================================
--- grass/trunk/temporal/t.vect.mapcalc/t.vect.mapcalc.py 2014-11-05 21:51:48 UTC (rev 62629)
+++ grass/trunk/temporal/t.vect.algebra/t.vect.mapcalc.py 2014-11-06 14:05:21 UTC (rev 62636)
@@ -1,71 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-############################################################################
-#
-# MODULE: t.vect.mapcalc
-# AUTHOR(S): Thomas Leppelt, Soeren Gebbert
-#
-# PURPOSE: Provide temporal vector algebra to perform spatial an temporal operations
-# for space time datasets by topological relationships to other space time
-# datasets.
-# COPYRIGHT: (C) 2014 by the GRASS Development Team
-#
-# This program is free software under the GNU General Public
-# License (version 2). Read the file COPYING that comes with GRASS
-# for details.
-#
-#############################################################################
-
-#%module
-#% description: Apply temporal and spatial oeprations on space time vector datasets using temporal vector algebra.
-#% keywords: temporal
-#% keywords: algebra
-#%end
-
-#%option
-#% key: expression
-#% type: string
-#% description: Spatio-temporal mapcalc expression
-#% key_desc: expression
-#% required : yes
-#%end
-
-#%option
-#% key: basename
-#% type: string
-#% label: Basename of the new generated output maps
-#% description: A numerical suffix separated by an underscore will be attached to create a unique identifier
-#% key_desc: basename
-#% required : yes
-#%end
-
-#%flag
-#% key: s
-#% description: Activate spatial topology
-#%end
-
-import grass.script
-import grass.temporal as tgis
-import sys
-
-def main():
- expression = options['expression']
- basename = options['basename']
- spatial = flags["s"]
- stdstype = "stvds"
-
- # Check for PLY istallation
- try:
- import ply.lex as lex
- import ply.yacc as yacc
- except:
- grass.script.fatal(_("Please install PLY (Lex and Yacc Python implementation) to use the temporal algebra modules."))
-
- tgis.init(True)
- p = tgis.TemporalVectorAlgebraParser(run = True, debug=False, spatial = spatial)
- p.parse(expression, basename, grass.script.overwrite())
-
-if __name__ == "__main__":
- options, flags = grass.script.parser()
- sys.exit(main())
-
Copied: grass/trunk/temporal/t.vect.algebra/testsuite/test.t.vect.algebra.sh (from rev 62629, grass/trunk/temporal/t.vect.mapcalc/testsuite/test.t.vect.mapcalc.sh)
===================================================================
--- grass/trunk/temporal/t.vect.algebra/testsuite/test.t.vect.algebra.sh (rev 0)
+++ grass/trunk/temporal/t.vect.algebra/testsuite/test.t.vect.algebra.sh 2014-11-06 14:05:21 UTC (rev 62636)
@@ -0,0 +1,96 @@
+#!/usr/bin/sh
+
+g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 -p
+
+export GRASS_OVERWRITE=1
+
+# Test for temporal algebra in LatLon location.
+if test -f vinput1_point_test ; then
+ rm vinput1_point_test.txt
+fi
+if test -f vinput1_point_test ; then
+ rm vinput2_point_test.txt
+fi
+if test -f vinput1_point_test ; then
+ rm vinput3_point_test.txt
+fi
+if test -f vinput1_point_test ; then
+ rm vinput4_point_test.txt
+fi
+
+if test -f vinput1_point_test ; then
+ rm vinput1_area_test.txt
+fi
+if test -f vinput1_point_test ; then
+ rm vinput2_area_test.txt
+fi
+if test -f vinput1_point_test ; then
+ rm vinput3_area_test.txt
+fi
+if test -f vinput1_point_test ; then
+ rm vinput4_area_test.txt
+fi
+
+LIST="1 2 3 4 5 6 7 8 9 0 10 11 12 13 14 15 16 17 18 19 20"
+
+# Create random area test maps.
+for i in ${LIST}
+ do
+ if test "$i" -le 10 ; then
+ echo vtestpoint1_$i >> vinput1_point_test.txt
+ echo vtestarea1_$i >> vinput1_area_test.txt
+ v.random --o -z output=vtestpoint1_$i n=3 seed=$i+1
+ v.voronoi --o input=vtestpoint1_$i output=vtestarea1_$i
+ elif test "$i" -gt 10 && test "$i" -le 15 ; then
+ echo vtestpoint2_$i >> vinput2_point_test.txt
+ echo vtestarea2_$i >> vinput2_area_test.txt
+ v.random --o -z output=vtestpoint2_$i n=3 seed=$i+1
+ v.voronoi --o input=vtestpoint2_$i output=vtestarea2_$i
+ else
+ echo vtestpoint3_$i >> vinput3_point_test.txt
+ echo vtestpoint4_$i >> vinput4_point_test.txt
+ echo vtestarea3_$i >> vinput3_area_test.txt
+ echo vtestarea4_$i >> vinput4_area_test.txt
+ v.random --o -z output=vtestpoint3_$i n=3 seed=$i+1
+ v.voronoi --o input=vtestpoint3_$i output=vtestarea3_$i
+ v.random --o -z output=vtestpoint4_$i n=3 seed=$i+1
+ v.voronoi --o input=vtestpoint4_$i output=vtestarea4_$i
+ fi
+ done
+
+# Create STVDS and register test maps.
+t.create output=A1 type=stvds title="Area test dataset" descr="Area test dataset"
+t.create output=A2 type=stvds title="Area test dataset" descr="Area test dataset"
+t.create output=A3 type=stvds title="Area test dataset" descr="Area test dataset"
+t.create output=A4 type=stvds title="Area test dataset" descr="Area test dataset"
+t.create output=P1 type=stvds title="Point test dataset" descr="Point test dataset"
+t.create output=P2 type=stvds title="Point test dataset" descr="Point test dataset"
+t.create output=P3 type=stvds title="Point test dataset" descr="Point test dataset"
+t.create output=P4 type=stvds title="Point test dataset" descr="Point test dataset"
+
+t.register -i type=vect input=A1 file=vinput1_area_test.txt increment="1 days" start="2013-01-01"
+t.register -i type=vect input=A2 file=vinput2_area_test.txt increment="1 days" start="2013-01-10"
+t.register -i type=vect input=A3 file=vinput3_area_test.txt increment="3 days" start="2013-01-01"
+t.register -i type=vect input=A4 file=vinput4_area_test.txt increment="3 days" start="2013-01-10"
+t.register -i type=vect input=P1 file=vinput1_point_test.txt increment="1 days" start="2013-01-01"
+t.register -i type=vect input=P2 file=vinput2_point_test.txt increment="1 days" start="2013-01-10"
+t.register -i type=vect input=P3 file=vinput3_point_test.txt increment="3 days" start="2013-01-01"
+t.register -i type=vect input=P4 file=vinput4_point_test.txt increment="3 days" start="2013-01-10"
+
+# Test different options.
+t.vect.algebra expression='B1 = A1 & A2' basename="bmap1"
+t.vect.list input=B1 column=name,start_time,end_time
+t.vect.algebra expression='B2 = A1 {+,equal|during,i} A3' basename="bmap2"
+t.vect.list input=B2 column=name,start_time,end_time
+t.vect.algebra expression='B3 = buff_p(P1,10)' basename="bmap3"
+t.vect.list input=B3 column=name,start_time,end_time
+t.vect.algebra expression='B4 = buff_p(P2,30) {|,equal|during} A4' basename="bmap4"
+t.vect.list input=B4 column=name,start_time,end_time
+t.vect.algebra expression='B5 = if(td(A1) == 1 || start_date(A1) >= "2010-01-10", A2)' basename="bmap5"
+t.vect.list input=B5 column=name,start_time,end_time
+t.vect.algebra expression='B6 = buff_p(P2,30) {&,equal|during|started,d} buff_p(P3,30)' basename="bmap6"
+t.vect.list input=B6 column=name,start_time,end_time
+t.vect.algebra expression='B7 = buff_p(P2,30) {&,starts,d} buff_p(P3,30)' basename="bmap7"
+t.vect.list input=B8 column=name,start_time,end_time
+t.vect.algebra expression='B8 = buff_p(P2,30) {|,starts,d} buff_p(P3,30)' basename="bmap8"
+t.vect.list input=B8 column=name,start_time,end_time
Deleted: grass/trunk/temporal/t.vect.algebra/testsuite/test.t.vect.mapcalc.sh
===================================================================
--- grass/trunk/temporal/t.vect.mapcalc/testsuite/test.t.vect.mapcalc.sh 2014-11-05 21:51:48 UTC (rev 62629)
+++ grass/trunk/temporal/t.vect.algebra/testsuite/test.t.vect.mapcalc.sh 2014-11-06 14:05:21 UTC (rev 62636)
@@ -1,96 +0,0 @@
-#!/usr/bin/sh
-
-g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 -p
-
-export GRASS_OVERWRITE=1
-
-# Test for temporal algebra in LatLon location.
-if test -f vinput1_point_test ; then
- rm vinput1_point_test.txt
-fi
-if test -f vinput1_point_test ; then
- rm vinput2_point_test.txt
-fi
-if test -f vinput1_point_test ; then
- rm vinput3_point_test.txt
-fi
-if test -f vinput1_point_test ; then
- rm vinput4_point_test.txt
-fi
-
-if test -f vinput1_point_test ; then
- rm vinput1_area_test.txt
-fi
-if test -f vinput1_point_test ; then
- rm vinput2_area_test.txt
-fi
-if test -f vinput1_point_test ; then
- rm vinput3_area_test.txt
-fi
-if test -f vinput1_point_test ; then
- rm vinput4_area_test.txt
-fi
-
-LIST="1 2 3 4 5 6 7 8 9 0 10 11 12 13 14 15 16 17 18 19 20"
-
-# Create random area test maps.
-for i in ${LIST}
- do
- if test "$i" -le 10 ; then
- echo vtestpoint1_$i >> vinput1_point_test.txt
- echo vtestarea1_$i >> vinput1_area_test.txt
- v.random --o -z output=vtestpoint1_$i n=3 seed=$i+1
- v.voronoi --o input=vtestpoint1_$i output=vtestarea1_$i
- elif test "$i" -gt 10 && test "$i" -le 15 ; then
- echo vtestpoint2_$i >> vinput2_point_test.txt
- echo vtestarea2_$i >> vinput2_area_test.txt
- v.random --o -z output=vtestpoint2_$i n=3 seed=$i+1
- v.voronoi --o input=vtestpoint2_$i output=vtestarea2_$i
- else
- echo vtestpoint3_$i >> vinput3_point_test.txt
- echo vtestpoint4_$i >> vinput4_point_test.txt
- echo vtestarea3_$i >> vinput3_area_test.txt
- echo vtestarea4_$i >> vinput4_area_test.txt
- v.random --o -z output=vtestpoint3_$i n=3 seed=$i+1
- v.voronoi --o input=vtestpoint3_$i output=vtestarea3_$i
- v.random --o -z output=vtestpoint4_$i n=3 seed=$i+1
- v.voronoi --o input=vtestpoint4_$i output=vtestarea4_$i
- fi
- done
-
-# Create STVDS and register test maps.
-t.create output=A1 type=stvds title="Area test dataset" descr="Area test dataset"
-t.create output=A2 type=stvds title="Area test dataset" descr="Area test dataset"
-t.create output=A3 type=stvds title="Area test dataset" descr="Area test dataset"
-t.create output=A4 type=stvds title="Area test dataset" descr="Area test dataset"
-t.create output=P1 type=stvds title="Point test dataset" descr="Point test dataset"
-t.create output=P2 type=stvds title="Point test dataset" descr="Point test dataset"
-t.create output=P3 type=stvds title="Point test dataset" descr="Point test dataset"
-t.create output=P4 type=stvds title="Point test dataset" descr="Point test dataset"
-
-t.register -i type=vect input=A1 file=vinput1_area_test.txt increment="1 days" start="2013-01-01"
-t.register -i type=vect input=A2 file=vinput2_area_test.txt increment="1 days" start="2013-01-10"
-t.register -i type=vect input=A3 file=vinput3_area_test.txt increment="3 days" start="2013-01-01"
-t.register -i type=vect input=A4 file=vinput4_area_test.txt increment="3 days" start="2013-01-10"
-t.register -i type=vect input=P1 file=vinput1_point_test.txt increment="1 days" start="2013-01-01"
-t.register -i type=vect input=P2 file=vinput2_point_test.txt increment="1 days" start="2013-01-10"
-t.register -i type=vect input=P3 file=vinput3_point_test.txt increment="3 days" start="2013-01-01"
-t.register -i type=vect input=P4 file=vinput4_point_test.txt increment="3 days" start="2013-01-10"
-
-# Test different options.
-t.vect.mapcalc expression='B1 = A1 & A2' basename="bmap1"
-t.vect.list input=B1 column=name,start_time,end_time
-t.vect.mapcalc expression='B2 = A1 {equal|during,+&} A3' basename="bmap2"
-t.vect.list input=B2 column=name,start_time,end_time
-t.vect.mapcalc expression='B3 = buff_p(P1,10)' basename="bmap3"
-t.vect.list input=B3 column=name,start_time,end_time
-t.vect.mapcalc expression='B4 = buff_p(P2,30) {equal|during,|^} A4' basename="bmap4"
-t.vect.list input=B4 column=name,start_time,end_time
-t.vect.mapcalc expression='B5 = if(td(A1) == 1 || start_date() >= "2010-01-10", A2)' basename="bmap5"
-t.vect.list input=B5 column=name,start_time,end_time
-t.vect.mapcalc expression='B6 = buff_p(P2,30) {equal|during|started,&^} buff_p(P3,30)' basename="bmap6"
-t.vect.list input=B6 column=name,start_time,end_time
-t.vect.mapcalc expression='B7 = buff_p(P2,30) {starts,&^} buff_p(P3,30)' basename="bmap7"
-t.vect.list input=B8 column=name,start_time,end_time
-t.vect.mapcalc expression='B8 = buff_p(P2,30) {starts,|^} buff_p(P3,30)' basename="bmap8"
-t.vect.list input=B8 column=name,start_time,end_time
More information about the grass-commit
mailing list