https://grasswiki.osgeo.org/w/api.php?action=feedcontributions&user=Mastho&feedformat=atomGRASS-Wiki - User contributions [en]2021-09-24T03:57:18ZUser contributionsMediaWiki 1.27.1https://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19748GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-09-22T09:57:24Z<p>Mastho: /* Weekly Reports */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= t.select =<br />
<br />
== Description ==<br />
t.select performs selection of maps that are registered in space time datasets using temporal algebra.<br />
<br />
== Program Use ==<br />
The module expects an <b>expression</b> as input parameter in the following form: <br><br />
<br><br />
<b> "result = expression" </b><br />
<br><br />
<br><br />
<br />
The statement structure is similar to r.mapcalc.<br />
Where <b>result</b> represents the name of a space time dataset (STDS)that will <br />
contain the result of the calculation that is given as <b>expression</b> <br />
on the right side of the equality sign. <br />
These expression can be any valid or nested combination of temporal <br />
operations and functions that are provided by the temporal algebra. <br><br />
The temporal algebra works with space time datasets of any type (STRDS, STR3DS and STVDS). <br />
The algebra provides methods for map selection from STDS based on their temporal relations. <br />
It is also possible to temporally shift maps, to create temporal buffer and to snap time <br />
instances to create a valid temporal topology. Furthermore expressions can be nested and <br />
evaluated in conditional statements (if, else statements). Within if-statements the algebra <br />
provides temporal variables like start time, end time, day of year, time differences or <br />
number of maps per time interval to build up conditions. These operations can be assigned <br />
to space time datasets or to the results of operations between space time datasets. <br />
<br><br />
<br><br />
The type of the input space time datasets must be defined with the input <br />
parameter <b>type</b>. Possible options are STRDS, STVDS or STR3DS. <br />
The default is set to space time raster datasets (STRDS).<br />
<br><br />
<br><br />
As default, topological relationships between space time datasets will be <br />
evaluated only temporal. Use the <b>s</b> flag to activate the <br />
additionally spatial topology evaluation.<br />
<br><br />
<br><br />
The expression option must be passed as <b>quoted</b> <br />
expression, for example: <br><br />
<div class="code"><pre>t.select expression="C = A : B"</pre></div> <br />
Where <b>C</b> is the new space time raster dataset that will contain maps<br />
from <b>A</b> that are selected by equal temporal relationships <br />
to the existing dataset <b>B</b> in this case. <br><br />
<br><br />
<br />
== Temporal Algebra for t.select==<br />
The temporal algebra provides a wide range of temporal operators and <br />
functions that will be presented in the following section. <br><br />
<br><br />
<br />
<h3>Temporal relations</h3><br />
<br />
Several temporal topology relations between space <br />
time datasets are supported: <br><br />
<div class="code"><pre><br />
equals A ------<br />
B ------<br />
<br />
during A ---- <br />
B ------<br />
<br />
contains A ------<br />
B ---- <br />
<br />
starts A ----<br />
B ------<br />
<br />
started A ------<br />
B ----<br />
<br />
finishs A ---- <br />
B ------<br />
<br />
finished A ------<br />
B ----<br />
<br />
precedes A ----<br />
B ----<br />
<br />
follows A ----<br />
B ----<br />
<br />
overlapped A ------<br />
B ------<br />
<br />
overlaps A ------<br />
B ------<br />
<br />
over booth overlaps and overlapped<br />
<br />
</pre></div><br />
The relations must be read as: A is related to B, like - A equals B - A is <br />
during B - A contains B <br><br />
<br><br />
Topological relations must be specified in {} parentheses. <br><br />
<br />
<h3>Temporal selection</h3><br />
<br />
The temporal selection simply selects parts of a space time dataset without <br />
processing raster or vector data.<br />
<br />
The algebra provides a selection operator <b>:</b> that selects parts <br />
of a space time dataset that are temporally equal to parts of a second one <br />
by default. The following expression<br />
<div class="code"><pre><br />
C = A : B<br />
</pre></div><br />
means: Select all parts of space time dataset A that are equal to B and store <br />
it in space time dataset C. The parts are in this case time stamped maps. <br><br />
<br><br />
In addition the inverse selection operator <b>!:</b> is defined as the complement of <br />
the selection operator, hence the following expression<br />
<div class="code"><pre><br />
C = A !: B<br />
</pre></div><br />
means: select all parts of space time time dataset A that are not equal to B <br />
and store it in space time dataset (STDS) C. <br><br />
<br><br />
To select parts of a STDS by different topological relations to other STDS, <br />
the temporal topology selection operator can be used. The operator consists of <br />
topological relations, that must be separated by the logical OR operator <br />
<b>||</b> and the temporal selection operator. Both parts are separated by <br />
comma and surrounded by curly braces: <br />
{"topological relations", "temporal selection operator"} <br><br />
<br><br />
Examples:<br />
<div class="code"><pre><br />
C = A {equals,:} B<br />
C = A {equals,!:} B<br />
</pre></div><br />
We can now define arbitrary topological relations using logical OR operator <br />
to connect them:<br />
<div class="code"><pre><br />
C = A {equals||during||overlaps,:} B<br />
</pre></div><br />
Select all parts of A that are equal to B, during B or overlaps B. <br><br />
<br><br />
The selection operator is implicitly contained in the temporal topology <br />
selection operator, so that the following statements are exactly the same:<br />
<div class="code"><pre><br />
C = A : B<br />
C = A {:} B<br />
C = A {equal,:} B<br />
</pre></div><br />
<br />
Same for the complementary selection:<br />
<div class="code"><pre><br />
C = A !: B<br />
C = A {!:} B<br />
C = A {equal,!:} B<br />
</pre></div><br />
<br />
<h3>Conditional statements</h3><br />
<br />
Selection operations can be evaluated within conditional statements.<br />
<br><br />
<div class="code"><pre><br />
Note A and B can either be space time datasets or expressions.<br />
<br />
if statement decision option temporal relations<br />
if(if, then, else)<br />
if(conditions, A) A if conditions are True; temporal topological relation between if and then is equal.<br />
if(conditions, A, B) A if conditions are True, B otherwise; temporal topological relation between if, then and else is equal.<br />
if(topologies, conditions, A) A if conditions are True; temporal topological relation between if and then is explicit specified by topologies.<br />
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.<br />
</pre></div><br />
The conditions are comparison expressions that are used to evaluate <br />
space time datasets. Specific values of temporal variables are <br />
compared by logical operators and evaluated for each map of the STDS.<br />
<br><br />
<br><br />
The supported logical operators:<br />
<div class="code"><pre><br />
Symbol description<br />
<br />
== equal<br />
!= not equal<br />
> greater than<br />
>= greater than or equal<br />
< less than<br />
<= less than or equal<br />
&& and<br />
|| or<br />
</pre></div><br />
<br />
Temporal functions: <br><br />
<div class="code"><pre><br />
<br />
td(A) Returns a list of time intervals of STDS A<br />
<br />
start_time() Start time as HH::MM:SS<br />
start_date() Start date as yyyy-mm-DD<br />
start_datetime() Start datetime as yyyy-mm-DD HH:MM:SS<br />
end_time() End time as HH:MM:SS<br />
end_date() End date as yyyy-mm-DD<br />
end_datetime() End datetime as yyyy-mm-DD HH:MM<br />
<br />
start_doy() Day of year (doy) from the start time [1 - 366]<br />
start_dow() Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1<br />
start_year() The year of the start time [0 - 9999]<br />
start_month() The month of the start time [1 - 12]<br />
start_week() Week of year of the start time [1 - 54]<br />
start_day() Day of month from the start time [1 - 31]<br />
start_hour() The hour of the start time [0 - 23]<br />
start_minute() The minute of the start time [0 - 59]<br />
start_second() The second of the start time [0 - 59]<br />
end_doy() Day of year (doy) from the end time [1 - 366]<br />
end_dow() Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1<br />
end_year() The year of the end time [0 - 9999]<br />
end_month() The month of the end time [1 - 12]<br />
end_week() Week of year of the end time [1 - 54]<br />
end_day() Day of month from the start time [1 - 31]<br />
end_hour() The hour of the end time [0 - 23]<br />
end_minute() The minute of the end time [0 - 59]<br />
end_second() The second of the end time [0 - 59] <br />
</pre></div><br />
<br />
Additionally the number of maps in intervals can be computed and <br />
used in conditional statements. <br><br />
The operator to count the number of maps <br />
is the hash <b>#</b>. <br />
<div class="code"><pre><br />
A{contains,#}B<br />
</pre></div><br />
This expression computes the number of maps from space <br />
time dataset B which are during the time intervals of maps from <br />
space time dataset A.<br><br />
A list of integers (scalars) corresponding to the maps of A <br />
that contain maps from B will be returned. <br><br />
<br><br />
<br />
Furthermore the temporal algebra allows temporal buffering, shifting <br />
and snapping with the functions buff_t(), tshift() and tsnap()<br />
respectively.<br />
<div class="code"><pre><br />
buff_t(A, size) Buffer STDS A with granule ("1 month" or 5)<br />
tshift(A, size) Shift STDS A with granule ("1 month" or 5)<br />
tsnap(A) Snap time instances and intervals of STDS A<br />
</pre></div><br />
<br />
<h3>Examples</h3><br />
<br />
Select all maps from space time dataset A which have equal time stamps <br />
with space time dataset B and C and are ealier that Jan. 1. 2005 and <br />
store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(start_date() < "2005-01-01", A : B : C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset A which contains more than three<br />
maps of space time dataset B, else select maps from C with time<br />
stamps that are not equal to A and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(A {contain, #} B > 3, A {contain, :} B, C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset B which are during the temporal <br />
buffered space time dataset A with a map interval of three days, else<br />
select maps from C and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(contain, td(buff_t(A, "1 days")) == 3, B, C)<br />
</pre></div><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || {{done}}<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || {{done}}<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || {{done}}<br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || {{done}}<br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| {{done}}<br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || {{done}}<br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || {{done}}<br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || {{done}}<br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || {{done}}<br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || {{done}}<br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || in progress<br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
== Week 9 - 2012-07-26 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented functions for temporal operators into the temporal algebra.<br />
* Finsihed the module t.select.<br />
* Wrote the manual page for t.select.<br />
* Started to implement vector operations into the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue documentation of the GRASS module t.select and the integration of the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 10 - 2012-08-02 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Fixed bugs in the temporal algebra.<br />
* More testing of the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the integration of the vector operations into the temporal vector algebra and write documentation and tests.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 11 - 2012-08-09 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Finished implementation of vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Integrated a new function to evaluate spatio-temporal operators with PLY.<br />
* Worked on a lot minor fixes and tests.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Finish the the temporal vector algebra and write documentation. Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 12 - 2012-08-16 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Integrated buffer function into temporal vector algebra.<br />
* Finished temporal vector algebra. <br />
* Worked on documentation and examples for the temporal vector algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write documentation and start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I travelled to Estonia for my PhD thesis, so I had limited time for my project.<br />
<br />
<br />
== Week 13 - 2012-08-23 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Write tests and documentation for the temporal vector algebra.<br />
* Fixed a lot of bugs in the temporal vector algebra.<br />
* Worked on examples for the temporal vector algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I was still busy with the temporal vector algebra this week. Some difficult and time intensive bugs prevent me from starting with the raster algebra.<br />
<br />
== Week 14 - 2012-08-30 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed some more bugs in the temporal vector algebra.<br />
* Made some improvements to speed up the meta data analysis.<br />
* Finished the temporal vector algebra.<br />
* Started with the temporal raster algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occurred<br />
<br />
== Week 15 - 2012-09-06 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Worked on the temporal raster algebra.<br />
* Implemented the lexical analysis for expressions.<br />
* Added arithmetic operations to the temporal raster algebra.<br />
* Rearrange the command list to work with r.mapcalc expression strings.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Occurring problems could be solved.<br />
<br />
== Week 16 - 2012-09-13 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Finished the temporal raster algebra.<br />
* Implemented the correct precedence for arithmetic operations.<br />
* Get the arithmetic operators running.<br />
* Improved and fixed the command list to work better with r.mapcalc expression strings.<br />
* Created the new module t.rast.mapcalc to work with the temporal raster algebra,<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Adding some more r.mapcalc functions to the temporal raster algebra and writing documentation for t.rast.mapcalc<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Occurring problems could be solved.<br />
<br />
<br />
== Week 17 - 2012-09-20 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Added additional functions to the raster algebra.<br />
* Wrote documentation for the temporal raster algebra.<br />
* Did intensive testing and fixed a lot bugs.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Writing some tutorials for the vector and raster algebra and add some more functions from r.mapcalc into the algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor issues.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19747GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-09-22T09:52:04Z<p>Mastho: /* Project plan */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= t.select =<br />
<br />
== Description ==<br />
t.select performs selection of maps that are registered in space time datasets using temporal algebra.<br />
<br />
== Program Use ==<br />
The module expects an <b>expression</b> as input parameter in the following form: <br><br />
<br><br />
<b> "result = expression" </b><br />
<br><br />
<br><br />
<br />
The statement structure is similar to r.mapcalc.<br />
Where <b>result</b> represents the name of a space time dataset (STDS)that will <br />
contain the result of the calculation that is given as <b>expression</b> <br />
on the right side of the equality sign. <br />
These expression can be any valid or nested combination of temporal <br />
operations and functions that are provided by the temporal algebra. <br><br />
The temporal algebra works with space time datasets of any type (STRDS, STR3DS and STVDS). <br />
The algebra provides methods for map selection from STDS based on their temporal relations. <br />
It is also possible to temporally shift maps, to create temporal buffer and to snap time <br />
instances to create a valid temporal topology. Furthermore expressions can be nested and <br />
evaluated in conditional statements (if, else statements). Within if-statements the algebra <br />
provides temporal variables like start time, end time, day of year, time differences or <br />
number of maps per time interval to build up conditions. These operations can be assigned <br />
to space time datasets or to the results of operations between space time datasets. <br />
<br><br />
<br><br />
The type of the input space time datasets must be defined with the input <br />
parameter <b>type</b>. Possible options are STRDS, STVDS or STR3DS. <br />
The default is set to space time raster datasets (STRDS).<br />
<br><br />
<br><br />
As default, topological relationships between space time datasets will be <br />
evaluated only temporal. Use the <b>s</b> flag to activate the <br />
additionally spatial topology evaluation.<br />
<br><br />
<br><br />
The expression option must be passed as <b>quoted</b> <br />
expression, for example: <br><br />
<div class="code"><pre>t.select expression="C = A : B"</pre></div> <br />
Where <b>C</b> is the new space time raster dataset that will contain maps<br />
from <b>A</b> that are selected by equal temporal relationships <br />
to the existing dataset <b>B</b> in this case. <br><br />
<br><br />
<br />
== Temporal Algebra for t.select==<br />
The temporal algebra provides a wide range of temporal operators and <br />
functions that will be presented in the following section. <br><br />
<br><br />
<br />
<h3>Temporal relations</h3><br />
<br />
Several temporal topology relations between space <br />
time datasets are supported: <br><br />
<div class="code"><pre><br />
equals A ------<br />
B ------<br />
<br />
during A ---- <br />
B ------<br />
<br />
contains A ------<br />
B ---- <br />
<br />
starts A ----<br />
B ------<br />
<br />
started A ------<br />
B ----<br />
<br />
finishs A ---- <br />
B ------<br />
<br />
finished A ------<br />
B ----<br />
<br />
precedes A ----<br />
B ----<br />
<br />
follows A ----<br />
B ----<br />
<br />
overlapped A ------<br />
B ------<br />
<br />
overlaps A ------<br />
B ------<br />
<br />
over booth overlaps and overlapped<br />
<br />
</pre></div><br />
The relations must be read as: A is related to B, like - A equals B - A is <br />
during B - A contains B <br><br />
<br><br />
Topological relations must be specified in {} parentheses. <br><br />
<br />
<h3>Temporal selection</h3><br />
<br />
The temporal selection simply selects parts of a space time dataset without <br />
processing raster or vector data.<br />
<br />
The algebra provides a selection operator <b>:</b> that selects parts <br />
of a space time dataset that are temporally equal to parts of a second one <br />
by default. The following expression<br />
<div class="code"><pre><br />
C = A : B<br />
</pre></div><br />
means: Select all parts of space time dataset A that are equal to B and store <br />
it in space time dataset C. The parts are in this case time stamped maps. <br><br />
<br><br />
In addition the inverse selection operator <b>!:</b> is defined as the complement of <br />
the selection operator, hence the following expression<br />
<div class="code"><pre><br />
C = A !: B<br />
</pre></div><br />
means: select all parts of space time time dataset A that are not equal to B <br />
and store it in space time dataset (STDS) C. <br><br />
<br><br />
To select parts of a STDS by different topological relations to other STDS, <br />
the temporal topology selection operator can be used. The operator consists of <br />
topological relations, that must be separated by the logical OR operator <br />
<b>||</b> and the temporal selection operator. Both parts are separated by <br />
comma and surrounded by curly braces: <br />
{"topological relations", "temporal selection operator"} <br><br />
<br><br />
Examples:<br />
<div class="code"><pre><br />
C = A {equals,:} B<br />
C = A {equals,!:} B<br />
</pre></div><br />
We can now define arbitrary topological relations using logical OR operator <br />
to connect them:<br />
<div class="code"><pre><br />
C = A {equals||during||overlaps,:} B<br />
</pre></div><br />
Select all parts of A that are equal to B, during B or overlaps B. <br><br />
<br><br />
The selection operator is implicitly contained in the temporal topology <br />
selection operator, so that the following statements are exactly the same:<br />
<div class="code"><pre><br />
C = A : B<br />
C = A {:} B<br />
C = A {equal,:} B<br />
</pre></div><br />
<br />
Same for the complementary selection:<br />
<div class="code"><pre><br />
C = A !: B<br />
C = A {!:} B<br />
C = A {equal,!:} B<br />
</pre></div><br />
<br />
<h3>Conditional statements</h3><br />
<br />
Selection operations can be evaluated within conditional statements.<br />
<br><br />
<div class="code"><pre><br />
Note A and B can either be space time datasets or expressions.<br />
<br />
if statement decision option temporal relations<br />
if(if, then, else)<br />
if(conditions, A) A if conditions are True; temporal topological relation between if and then is equal.<br />
if(conditions, A, B) A if conditions are True, B otherwise; temporal topological relation between if, then and else is equal.<br />
if(topologies, conditions, A) A if conditions are True; temporal topological relation between if and then is explicit specified by topologies.<br />
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.<br />
</pre></div><br />
The conditions are comparison expressions that are used to evaluate <br />
space time datasets. Specific values of temporal variables are <br />
compared by logical operators and evaluated for each map of the STDS.<br />
<br><br />
<br><br />
The supported logical operators:<br />
<div class="code"><pre><br />
Symbol description<br />
<br />
== equal<br />
!= not equal<br />
> greater than<br />
>= greater than or equal<br />
< less than<br />
<= less than or equal<br />
&& and<br />
|| or<br />
</pre></div><br />
<br />
Temporal functions: <br><br />
<div class="code"><pre><br />
<br />
td(A) Returns a list of time intervals of STDS A<br />
<br />
start_time() Start time as HH::MM:SS<br />
start_date() Start date as yyyy-mm-DD<br />
start_datetime() Start datetime as yyyy-mm-DD HH:MM:SS<br />
end_time() End time as HH:MM:SS<br />
end_date() End date as yyyy-mm-DD<br />
end_datetime() End datetime as yyyy-mm-DD HH:MM<br />
<br />
start_doy() Day of year (doy) from the start time [1 - 366]<br />
start_dow() Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1<br />
start_year() The year of the start time [0 - 9999]<br />
start_month() The month of the start time [1 - 12]<br />
start_week() Week of year of the start time [1 - 54]<br />
start_day() Day of month from the start time [1 - 31]<br />
start_hour() The hour of the start time [0 - 23]<br />
start_minute() The minute of the start time [0 - 59]<br />
start_second() The second of the start time [0 - 59]<br />
end_doy() Day of year (doy) from the end time [1 - 366]<br />
end_dow() Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1<br />
end_year() The year of the end time [0 - 9999]<br />
end_month() The month of the end time [1 - 12]<br />
end_week() Week of year of the end time [1 - 54]<br />
end_day() Day of month from the start time [1 - 31]<br />
end_hour() The hour of the end time [0 - 23]<br />
end_minute() The minute of the end time [0 - 59]<br />
end_second() The second of the end time [0 - 59] <br />
</pre></div><br />
<br />
Additionally the number of maps in intervals can be computed and <br />
used in conditional statements. <br><br />
The operator to count the number of maps <br />
is the hash <b>#</b>. <br />
<div class="code"><pre><br />
A{contains,#}B<br />
</pre></div><br />
This expression computes the number of maps from space <br />
time dataset B which are during the time intervals of maps from <br />
space time dataset A.<br><br />
A list of integers (scalars) corresponding to the maps of A <br />
that contain maps from B will be returned. <br><br />
<br><br />
<br />
Furthermore the temporal algebra allows temporal buffering, shifting <br />
and snapping with the functions buff_t(), tshift() and tsnap()<br />
respectively.<br />
<div class="code"><pre><br />
buff_t(A, size) Buffer STDS A with granule ("1 month" or 5)<br />
tshift(A, size) Shift STDS A with granule ("1 month" or 5)<br />
tsnap(A) Snap time instances and intervals of STDS A<br />
</pre></div><br />
<br />
<h3>Examples</h3><br />
<br />
Select all maps from space time dataset A which have equal time stamps <br />
with space time dataset B and C and are ealier that Jan. 1. 2005 and <br />
store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(start_date() < "2005-01-01", A : B : C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset A which contains more than three<br />
maps of space time dataset B, else select maps from C with time<br />
stamps that are not equal to A and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(A {contain, #} B > 3, A {contain, :} B, C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset B which are during the temporal <br />
buffered space time dataset A with a map interval of three days, else<br />
select maps from C and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(contain, td(buff_t(A, "1 days")) == 3, B, C)<br />
</pre></div><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || {{done}}<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || {{done}}<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || {{done}}<br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || {{done}}<br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| {{done}}<br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || {{done}}<br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || {{done}}<br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || {{done}}<br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || {{done}}<br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || {{done}}<br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || in progress<br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
== Week 9 - 2012-07-26 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented functions for temporal operators into the temporal algebra.<br />
* Finsihed the module t.select.<br />
* Wrote the manual page for t.select.<br />
* Started to implement vector operations into the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue documentation of the GRASS module t.select and the integration of the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 10 - 2012-08-02 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Fixed bugs in the temporal algebra.<br />
* More testing of the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the integration of the vector operations into the temporal vector algebra and write documentation and tests.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 11 - 2012-08-09 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Finished implementation of vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Integrated a new function to evaluate spatio-temporal operators with PLY.<br />
* Worked on a lot minor fixes and tests.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Finish the the temporal vector algebra and write documentation. Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 12 - 2012-08-16 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Integrated buffer function into temporal vector algebra.<br />
* Finished temporal vector algebra. <br />
* Worked on documentation and examples for the temporal vector algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write documentation and start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I travelled to Estonia for my PhD thesis, so I had limited time for my project.<br />
<br />
<br />
== Week 13 - 2012-08-23 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Write tests and documentation for the temporal vector algebra.<br />
* Fixed a lot of bugs in the temporal vector algebra.<br />
* Worked on examples for the temporal vector algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I was still busy with the temporal vector algebra this week. Some difficult and time intensive bugs prevent me from starting with the raster algebra.<br />
<br />
== Week 14 - 2012-08-30 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed some more bugs in the temporal vector algebra.<br />
* Made some improvements to speed up the meta data analysis.<br />
* Finished the temporal vector algebra.<br />
* Started with the temporal raster algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occurred<br />
<br />
== Week 15 - 2012-09-06 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Worked on the temporal raster algebra.<br />
* Implemented the lexical analysis for expressions.<br />
* Added arithmetic operations to the temporal raster algebra.<br />
* Rearrange the command list to work with r.mapcalc expression strings.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Occurring problems could be solved.<br />
<br />
== Week 16 - 2012-09-13 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Finished the temporal raster algebra.<br />
* Implemented the correct precedence for arithmetic operations.<br />
* Get the arithmetic operators running.<br />
* Improved and fixed the command list to work better with r.mapcalc expression strings.<br />
* Created the new module t.rast.mapcalc to work with the temporal raster algebra,<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Adding some more r.mapcalc functions to the temporal raster algebra and writing documentation for t.rast.mapcalc<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Occurring problems could be solved.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19724GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-09-13T19:40:06Z<p>Mastho: /* Weekly Reports */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= t.select =<br />
<br />
== Description ==<br />
t.select performs selection of maps that are registered in space time datasets using temporal algebra.<br />
<br />
== Program Use ==<br />
The module expects an <b>expression</b> as input parameter in the following form: <br><br />
<br><br />
<b> "result = expression" </b><br />
<br><br />
<br><br />
<br />
The statement structure is similar to r.mapcalc.<br />
Where <b>result</b> represents the name of a space time dataset (STDS)that will <br />
contain the result of the calculation that is given as <b>expression</b> <br />
on the right side of the equality sign. <br />
These expression can be any valid or nested combination of temporal <br />
operations and functions that are provided by the temporal algebra. <br><br />
The temporal algebra works with space time datasets of any type (STRDS, STR3DS and STVDS). <br />
The algebra provides methods for map selection from STDS based on their temporal relations. <br />
It is also possible to temporally shift maps, to create temporal buffer and to snap time <br />
instances to create a valid temporal topology. Furthermore expressions can be nested and <br />
evaluated in conditional statements (if, else statements). Within if-statements the algebra <br />
provides temporal variables like start time, end time, day of year, time differences or <br />
number of maps per time interval to build up conditions. These operations can be assigned <br />
to space time datasets or to the results of operations between space time datasets. <br />
<br><br />
<br><br />
The type of the input space time datasets must be defined with the input <br />
parameter <b>type</b>. Possible options are STRDS, STVDS or STR3DS. <br />
The default is set to space time raster datasets (STRDS).<br />
<br><br />
<br><br />
As default, topological relationships between space time datasets will be <br />
evaluated only temporal. Use the <b>s</b> flag to activate the <br />
additionally spatial topology evaluation.<br />
<br><br />
<br><br />
The expression option must be passed as <b>quoted</b> <br />
expression, for example: <br><br />
<div class="code"><pre>t.select expression="C = A : B"</pre></div> <br />
Where <b>C</b> is the new space time raster dataset that will contain maps<br />
from <b>A</b> that are selected by equal temporal relationships <br />
to the existing dataset <b>B</b> in this case. <br><br />
<br><br />
<br />
== Temporal Algebra for t.select==<br />
The temporal algebra provides a wide range of temporal operators and <br />
functions that will be presented in the following section. <br><br />
<br><br />
<br />
<h3>Temporal relations</h3><br />
<br />
Several temporal topology relations between space <br />
time datasets are supported: <br><br />
<div class="code"><pre><br />
equals A ------<br />
B ------<br />
<br />
during A ---- <br />
B ------<br />
<br />
contains A ------<br />
B ---- <br />
<br />
starts A ----<br />
B ------<br />
<br />
started A ------<br />
B ----<br />
<br />
finishs A ---- <br />
B ------<br />
<br />
finished A ------<br />
B ----<br />
<br />
precedes A ----<br />
B ----<br />
<br />
follows A ----<br />
B ----<br />
<br />
overlapped A ------<br />
B ------<br />
<br />
overlaps A ------<br />
B ------<br />
<br />
over booth overlaps and overlapped<br />
<br />
</pre></div><br />
The relations must be read as: A is related to B, like - A equals B - A is <br />
during B - A contains B <br><br />
<br><br />
Topological relations must be specified in {} parentheses. <br><br />
<br />
<h3>Temporal selection</h3><br />
<br />
The temporal selection simply selects parts of a space time dataset without <br />
processing raster or vector data.<br />
<br />
The algebra provides a selection operator <b>:</b> that selects parts <br />
of a space time dataset that are temporally equal to parts of a second one <br />
by default. The following expression<br />
<div class="code"><pre><br />
C = A : B<br />
</pre></div><br />
means: Select all parts of space time dataset A that are equal to B and store <br />
it in space time dataset C. The parts are in this case time stamped maps. <br><br />
<br><br />
In addition the inverse selection operator <b>!:</b> is defined as the complement of <br />
the selection operator, hence the following expression<br />
<div class="code"><pre><br />
C = A !: B<br />
</pre></div><br />
means: select all parts of space time time dataset A that are not equal to B <br />
and store it in space time dataset (STDS) C. <br><br />
<br><br />
To select parts of a STDS by different topological relations to other STDS, <br />
the temporal topology selection operator can be used. The operator consists of <br />
topological relations, that must be separated by the logical OR operator <br />
<b>||</b> and the temporal selection operator. Both parts are separated by <br />
comma and surrounded by curly braces: <br />
{"topological relations", "temporal selection operator"} <br><br />
<br><br />
Examples:<br />
<div class="code"><pre><br />
C = A {equals,:} B<br />
C = A {equals,!:} B<br />
</pre></div><br />
We can now define arbitrary topological relations using logical OR operator <br />
to connect them:<br />
<div class="code"><pre><br />
C = A {equals||during||overlaps,:} B<br />
</pre></div><br />
Select all parts of A that are equal to B, during B or overlaps B. <br><br />
<br><br />
The selection operator is implicitly contained in the temporal topology <br />
selection operator, so that the following statements are exactly the same:<br />
<div class="code"><pre><br />
C = A : B<br />
C = A {:} B<br />
C = A {equal,:} B<br />
</pre></div><br />
<br />
Same for the complementary selection:<br />
<div class="code"><pre><br />
C = A !: B<br />
C = A {!:} B<br />
C = A {equal,!:} B<br />
</pre></div><br />
<br />
<h3>Conditional statements</h3><br />
<br />
Selection operations can be evaluated within conditional statements.<br />
<br><br />
<div class="code"><pre><br />
Note A and B can either be space time datasets or expressions.<br />
<br />
if statement decision option temporal relations<br />
if(if, then, else)<br />
if(conditions, A) A if conditions are True; temporal topological relation between if and then is equal.<br />
if(conditions, A, B) A if conditions are True, B otherwise; temporal topological relation between if, then and else is equal.<br />
if(topologies, conditions, A) A if conditions are True; temporal topological relation between if and then is explicit specified by topologies.<br />
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.<br />
</pre></div><br />
The conditions are comparison expressions that are used to evaluate <br />
space time datasets. Specific values of temporal variables are <br />
compared by logical operators and evaluated for each map of the STDS.<br />
<br><br />
<br><br />
The supported logical operators:<br />
<div class="code"><pre><br />
Symbol description<br />
<br />
== equal<br />
!= not equal<br />
> greater than<br />
>= greater than or equal<br />
< less than<br />
<= less than or equal<br />
&& and<br />
|| or<br />
</pre></div><br />
<br />
Temporal functions: <br><br />
<div class="code"><pre><br />
<br />
td(A) Returns a list of time intervals of STDS A<br />
<br />
start_time() Start time as HH::MM:SS<br />
start_date() Start date as yyyy-mm-DD<br />
start_datetime() Start datetime as yyyy-mm-DD HH:MM:SS<br />
end_time() End time as HH:MM:SS<br />
end_date() End date as yyyy-mm-DD<br />
end_datetime() End datetime as yyyy-mm-DD HH:MM<br />
<br />
start_doy() Day of year (doy) from the start time [1 - 366]<br />
start_dow() Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1<br />
start_year() The year of the start time [0 - 9999]<br />
start_month() The month of the start time [1 - 12]<br />
start_week() Week of year of the start time [1 - 54]<br />
start_day() Day of month from the start time [1 - 31]<br />
start_hour() The hour of the start time [0 - 23]<br />
start_minute() The minute of the start time [0 - 59]<br />
start_second() The second of the start time [0 - 59]<br />
end_doy() Day of year (doy) from the end time [1 - 366]<br />
end_dow() Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1<br />
end_year() The year of the end time [0 - 9999]<br />
end_month() The month of the end time [1 - 12]<br />
end_week() Week of year of the end time [1 - 54]<br />
end_day() Day of month from the start time [1 - 31]<br />
end_hour() The hour of the end time [0 - 23]<br />
end_minute() The minute of the end time [0 - 59]<br />
end_second() The second of the end time [0 - 59] <br />
</pre></div><br />
<br />
Additionally the number of maps in intervals can be computed and <br />
used in conditional statements. <br><br />
The operator to count the number of maps <br />
is the hash <b>#</b>. <br />
<div class="code"><pre><br />
A{contains,#}B<br />
</pre></div><br />
This expression computes the number of maps from space <br />
time dataset B which are during the time intervals of maps from <br />
space time dataset A.<br><br />
A list of integers (scalars) corresponding to the maps of A <br />
that contain maps from B will be returned. <br><br />
<br><br />
<br />
Furthermore the temporal algebra allows temporal buffering, shifting <br />
and snapping with the functions buff_t(), tshift() and tsnap()<br />
respectively.<br />
<div class="code"><pre><br />
buff_t(A, size) Buffer STDS A with granule ("1 month" or 5)<br />
tshift(A, size) Shift STDS A with granule ("1 month" or 5)<br />
tsnap(A) Snap time instances and intervals of STDS A<br />
</pre></div><br />
<br />
<h3>Examples</h3><br />
<br />
Select all maps from space time dataset A which have equal time stamps <br />
with space time dataset B and C and are ealier that Jan. 1. 2005 and <br />
store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(start_date() < "2005-01-01", A : B : C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset A which contains more than three<br />
maps of space time dataset B, else select maps from C with time<br />
stamps that are not equal to A and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(A {contain, #} B > 3, A {contain, :} B, C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset B which are during the temporal <br />
buffered space time dataset A with a map interval of three days, else<br />
select maps from C and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(contain, td(buff_t(A, "1 days")) == 3, B, C)<br />
</pre></div><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || {{done}}<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || {{done}}<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || {{done}}<br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || {{done}}<br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| {{done}}<br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || {{done}}<br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || {{done}}<br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || {{done}}<br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || in progress<br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
== Week 9 - 2012-07-26 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented functions for temporal operators into the temporal algebra.<br />
* Finsihed the module t.select.<br />
* Wrote the manual page for t.select.<br />
* Started to implement vector operations into the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue documentation of the GRASS module t.select and the integration of the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 10 - 2012-08-02 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Fixed bugs in the temporal algebra.<br />
* More testing of the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the integration of the vector operations into the temporal vector algebra and write documentation and tests.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 11 - 2012-08-09 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Finished implementation of vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Integrated a new function to evaluate spatio-temporal operators with PLY.<br />
* Worked on a lot minor fixes and tests.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Finish the the temporal vector algebra and write documentation. Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 12 - 2012-08-16 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Integrated buffer function into temporal vector algebra.<br />
* Finished temporal vector algebra. <br />
* Worked on documentation and examples for the temporal vector algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write documentation and start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I travelled to Estonia for my PhD thesis, so I had limited time for my project.<br />
<br />
<br />
== Week 13 - 2012-08-23 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Write tests and documentation for the temporal vector algebra.<br />
* Fixed a lot of bugs in the temporal vector algebra.<br />
* Worked on examples for the temporal vector algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I was still busy with the temporal vector algebra this week. Some difficult and time intensive bugs prevent me from starting with the raster algebra.<br />
<br />
== Week 14 - 2012-08-30 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed some more bugs in the temporal vector algebra.<br />
* Made some improvements to speed up the meta data analysis.<br />
* Finished the temporal vector algebra.<br />
* Started with the temporal raster algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occurred<br />
<br />
== Week 15 - 2012-09-06 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Worked on the temporal raster algebra.<br />
* Implemented the lexical analysis for expressions.<br />
* Added arithmetic operations to the temporal raster algebra.<br />
* Rearrange the command list to work with r.mapcalc expression strings.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Occurring problems could be solved.<br />
<br />
== Week 16 - 2012-09-13 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Finished the temporal raster algebra.<br />
* Implemented the correct precedence for arithmetic operations.<br />
* Get the arithmetic operators running.<br />
* Improved and fixed the command list to work better with r.mapcalc expression strings.<br />
* Created the new module t.rast.mapcalc to work with the temporal raster algebra,<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Adding some more r.mapcalc functions to the temporal raster algebra and writing documentation for t.rast.mapcalc<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Occurring problems could be solved.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19723GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-09-13T19:35:53Z<p>Mastho: /* Project plan */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= t.select =<br />
<br />
== Description ==<br />
t.select performs selection of maps that are registered in space time datasets using temporal algebra.<br />
<br />
== Program Use ==<br />
The module expects an <b>expression</b> as input parameter in the following form: <br><br />
<br><br />
<b> "result = expression" </b><br />
<br><br />
<br><br />
<br />
The statement structure is similar to r.mapcalc.<br />
Where <b>result</b> represents the name of a space time dataset (STDS)that will <br />
contain the result of the calculation that is given as <b>expression</b> <br />
on the right side of the equality sign. <br />
These expression can be any valid or nested combination of temporal <br />
operations and functions that are provided by the temporal algebra. <br><br />
The temporal algebra works with space time datasets of any type (STRDS, STR3DS and STVDS). <br />
The algebra provides methods for map selection from STDS based on their temporal relations. <br />
It is also possible to temporally shift maps, to create temporal buffer and to snap time <br />
instances to create a valid temporal topology. Furthermore expressions can be nested and <br />
evaluated in conditional statements (if, else statements). Within if-statements the algebra <br />
provides temporal variables like start time, end time, day of year, time differences or <br />
number of maps per time interval to build up conditions. These operations can be assigned <br />
to space time datasets or to the results of operations between space time datasets. <br />
<br><br />
<br><br />
The type of the input space time datasets must be defined with the input <br />
parameter <b>type</b>. Possible options are STRDS, STVDS or STR3DS. <br />
The default is set to space time raster datasets (STRDS).<br />
<br><br />
<br><br />
As default, topological relationships between space time datasets will be <br />
evaluated only temporal. Use the <b>s</b> flag to activate the <br />
additionally spatial topology evaluation.<br />
<br><br />
<br><br />
The expression option must be passed as <b>quoted</b> <br />
expression, for example: <br><br />
<div class="code"><pre>t.select expression="C = A : B"</pre></div> <br />
Where <b>C</b> is the new space time raster dataset that will contain maps<br />
from <b>A</b> that are selected by equal temporal relationships <br />
to the existing dataset <b>B</b> in this case. <br><br />
<br><br />
<br />
== Temporal Algebra for t.select==<br />
The temporal algebra provides a wide range of temporal operators and <br />
functions that will be presented in the following section. <br><br />
<br><br />
<br />
<h3>Temporal relations</h3><br />
<br />
Several temporal topology relations between space <br />
time datasets are supported: <br><br />
<div class="code"><pre><br />
equals A ------<br />
B ------<br />
<br />
during A ---- <br />
B ------<br />
<br />
contains A ------<br />
B ---- <br />
<br />
starts A ----<br />
B ------<br />
<br />
started A ------<br />
B ----<br />
<br />
finishs A ---- <br />
B ------<br />
<br />
finished A ------<br />
B ----<br />
<br />
precedes A ----<br />
B ----<br />
<br />
follows A ----<br />
B ----<br />
<br />
overlapped A ------<br />
B ------<br />
<br />
overlaps A ------<br />
B ------<br />
<br />
over booth overlaps and overlapped<br />
<br />
</pre></div><br />
The relations must be read as: A is related to B, like - A equals B - A is <br />
during B - A contains B <br><br />
<br><br />
Topological relations must be specified in {} parentheses. <br><br />
<br />
<h3>Temporal selection</h3><br />
<br />
The temporal selection simply selects parts of a space time dataset without <br />
processing raster or vector data.<br />
<br />
The algebra provides a selection operator <b>:</b> that selects parts <br />
of a space time dataset that are temporally equal to parts of a second one <br />
by default. The following expression<br />
<div class="code"><pre><br />
C = A : B<br />
</pre></div><br />
means: Select all parts of space time dataset A that are equal to B and store <br />
it in space time dataset C. The parts are in this case time stamped maps. <br><br />
<br><br />
In addition the inverse selection operator <b>!:</b> is defined as the complement of <br />
the selection operator, hence the following expression<br />
<div class="code"><pre><br />
C = A !: B<br />
</pre></div><br />
means: select all parts of space time time dataset A that are not equal to B <br />
and store it in space time dataset (STDS) C. <br><br />
<br><br />
To select parts of a STDS by different topological relations to other STDS, <br />
the temporal topology selection operator can be used. The operator consists of <br />
topological relations, that must be separated by the logical OR operator <br />
<b>||</b> and the temporal selection operator. Both parts are separated by <br />
comma and surrounded by curly braces: <br />
{"topological relations", "temporal selection operator"} <br><br />
<br><br />
Examples:<br />
<div class="code"><pre><br />
C = A {equals,:} B<br />
C = A {equals,!:} B<br />
</pre></div><br />
We can now define arbitrary topological relations using logical OR operator <br />
to connect them:<br />
<div class="code"><pre><br />
C = A {equals||during||overlaps,:} B<br />
</pre></div><br />
Select all parts of A that are equal to B, during B or overlaps B. <br><br />
<br><br />
The selection operator is implicitly contained in the temporal topology <br />
selection operator, so that the following statements are exactly the same:<br />
<div class="code"><pre><br />
C = A : B<br />
C = A {:} B<br />
C = A {equal,:} B<br />
</pre></div><br />
<br />
Same for the complementary selection:<br />
<div class="code"><pre><br />
C = A !: B<br />
C = A {!:} B<br />
C = A {equal,!:} B<br />
</pre></div><br />
<br />
<h3>Conditional statements</h3><br />
<br />
Selection operations can be evaluated within conditional statements.<br />
<br><br />
<div class="code"><pre><br />
Note A and B can either be space time datasets or expressions.<br />
<br />
if statement decision option temporal relations<br />
if(if, then, else)<br />
if(conditions, A) A if conditions are True; temporal topological relation between if and then is equal.<br />
if(conditions, A, B) A if conditions are True, B otherwise; temporal topological relation between if, then and else is equal.<br />
if(topologies, conditions, A) A if conditions are True; temporal topological relation between if and then is explicit specified by topologies.<br />
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.<br />
</pre></div><br />
The conditions are comparison expressions that are used to evaluate <br />
space time datasets. Specific values of temporal variables are <br />
compared by logical operators and evaluated for each map of the STDS.<br />
<br><br />
<br><br />
The supported logical operators:<br />
<div class="code"><pre><br />
Symbol description<br />
<br />
== equal<br />
!= not equal<br />
> greater than<br />
>= greater than or equal<br />
< less than<br />
<= less than or equal<br />
&& and<br />
|| or<br />
</pre></div><br />
<br />
Temporal functions: <br><br />
<div class="code"><pre><br />
<br />
td(A) Returns a list of time intervals of STDS A<br />
<br />
start_time() Start time as HH::MM:SS<br />
start_date() Start date as yyyy-mm-DD<br />
start_datetime() Start datetime as yyyy-mm-DD HH:MM:SS<br />
end_time() End time as HH:MM:SS<br />
end_date() End date as yyyy-mm-DD<br />
end_datetime() End datetime as yyyy-mm-DD HH:MM<br />
<br />
start_doy() Day of year (doy) from the start time [1 - 366]<br />
start_dow() Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1<br />
start_year() The year of the start time [0 - 9999]<br />
start_month() The month of the start time [1 - 12]<br />
start_week() Week of year of the start time [1 - 54]<br />
start_day() Day of month from the start time [1 - 31]<br />
start_hour() The hour of the start time [0 - 23]<br />
start_minute() The minute of the start time [0 - 59]<br />
start_second() The second of the start time [0 - 59]<br />
end_doy() Day of year (doy) from the end time [1 - 366]<br />
end_dow() Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1<br />
end_year() The year of the end time [0 - 9999]<br />
end_month() The month of the end time [1 - 12]<br />
end_week() Week of year of the end time [1 - 54]<br />
end_day() Day of month from the start time [1 - 31]<br />
end_hour() The hour of the end time [0 - 23]<br />
end_minute() The minute of the end time [0 - 59]<br />
end_second() The second of the end time [0 - 59] <br />
</pre></div><br />
<br />
Additionally the number of maps in intervals can be computed and <br />
used in conditional statements. <br><br />
The operator to count the number of maps <br />
is the hash <b>#</b>. <br />
<div class="code"><pre><br />
A{contains,#}B<br />
</pre></div><br />
This expression computes the number of maps from space <br />
time dataset B which are during the time intervals of maps from <br />
space time dataset A.<br><br />
A list of integers (scalars) corresponding to the maps of A <br />
that contain maps from B will be returned. <br><br />
<br><br />
<br />
Furthermore the temporal algebra allows temporal buffering, shifting <br />
and snapping with the functions buff_t(), tshift() and tsnap()<br />
respectively.<br />
<div class="code"><pre><br />
buff_t(A, size) Buffer STDS A with granule ("1 month" or 5)<br />
tshift(A, size) Shift STDS A with granule ("1 month" or 5)<br />
tsnap(A) Snap time instances and intervals of STDS A<br />
</pre></div><br />
<br />
<h3>Examples</h3><br />
<br />
Select all maps from space time dataset A which have equal time stamps <br />
with space time dataset B and C and are ealier that Jan. 1. 2005 and <br />
store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(start_date() < "2005-01-01", A : B : C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset A which contains more than three<br />
maps of space time dataset B, else select maps from C with time<br />
stamps that are not equal to A and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(A {contain, #} B > 3, A {contain, :} B, C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset B which are during the temporal <br />
buffered space time dataset A with a map interval of three days, else<br />
select maps from C and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(contain, td(buff_t(A, "1 days")) == 3, B, C)<br />
</pre></div><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || {{done}}<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || {{done}}<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || {{done}}<br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || {{done}}<br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| {{done}}<br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || {{done}}<br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || {{done}}<br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || {{done}}<br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || in progress<br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
== Week 9 - 2012-07-26 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented functions for temporal operators into the temporal algebra.<br />
* Finsihed the module t.select.<br />
* Wrote the manual page for t.select.<br />
* Started to implement vector operations into the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue documentation of the GRASS module t.select and the integration of the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 10 - 2012-08-02 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Fixed bugs in the temporal algebra.<br />
* More testing of the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the integration of the vector operations into the temporal vector algebra and write documentation and tests.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 11 - 2012-08-09 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Finished implementation of vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Integrated a new function to evaluate spatio-temporal operators with PLY.<br />
* Worked on a lot minor fixes and tests.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Finish the the temporal vector algebra and write documentation. Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 12 - 2012-08-16 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Integrated buffer function into temporal vector algebra.<br />
* Finished temporal vector algebra. <br />
* Worked on documentation and examples for the temporal vector algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write documentation and start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I travelled to Estonia for my PhD thesis, so I had limited time for my project.<br />
<br />
<br />
== Week 13 - 2012-08-23 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Write tests and documentation for the temporal vector algebra.<br />
* Fixed a lot of bugs in the temporal vector algebra.<br />
* Worked on examples for the temporal vector algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I was still busy with the temporal vector algebra this week. Some difficult and time intensive bugs prevent me from starting with the raster algebra.<br />
<br />
== Week 14 - 2012-08-30 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed some more bugs in the temporal vector algebra.<br />
* Made some improvements to speed up the meta data analysis.<br />
* Finished the temporal vector algebra.<br />
* Started with the temporal raster algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occurred<br />
<br />
== Week 15 - 2012-09-06 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Worked on the temporal raster algebra.<br />
* Implemented the lexical analysis for expressions.<br />
* Added arithmetic operations to the temporal raster algebra.<br />
* Rearrange the command list to work with r.mapcalc expression strings.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Occurring problems could be solved.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19687GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-09-06T14:13:45Z<p>Mastho: /* Weekly Reports */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= t.select =<br />
<br />
== Description ==<br />
t.select performs selection of maps that are registered in space time datasets using temporal algebra.<br />
<br />
== Program Use ==<br />
The module expects an <b>expression</b> as input parameter in the following form: <br><br />
<br><br />
<b> "result = expression" </b><br />
<br><br />
<br><br />
<br />
The statement structure is similar to r.mapcalc.<br />
Where <b>result</b> represents the name of a space time dataset (STDS)that will <br />
contain the result of the calculation that is given as <b>expression</b> <br />
on the right side of the equality sign. <br />
These expression can be any valid or nested combination of temporal <br />
operations and functions that are provided by the temporal algebra. <br><br />
The temporal algebra works with space time datasets of any type (STRDS, STR3DS and STVDS). <br />
The algebra provides methods for map selection from STDS based on their temporal relations. <br />
It is also possible to temporally shift maps, to create temporal buffer and to snap time <br />
instances to create a valid temporal topology. Furthermore expressions can be nested and <br />
evaluated in conditional statements (if, else statements). Within if-statements the algebra <br />
provides temporal variables like start time, end time, day of year, time differences or <br />
number of maps per time interval to build up conditions. These operations can be assigned <br />
to space time datasets or to the results of operations between space time datasets. <br />
<br><br />
<br><br />
The type of the input space time datasets must be defined with the input <br />
parameter <b>type</b>. Possible options are STRDS, STVDS or STR3DS. <br />
The default is set to space time raster datasets (STRDS).<br />
<br><br />
<br><br />
As default, topological relationships between space time datasets will be <br />
evaluated only temporal. Use the <b>s</b> flag to activate the <br />
additionally spatial topology evaluation.<br />
<br><br />
<br><br />
The expression option must be passed as <b>quoted</b> <br />
expression, for example: <br><br />
<div class="code"><pre>t.select expression="C = A : B"</pre></div> <br />
Where <b>C</b> is the new space time raster dataset that will contain maps<br />
from <b>A</b> that are selected by equal temporal relationships <br />
to the existing dataset <b>B</b> in this case. <br><br />
<br><br />
<br />
== Temporal Algebra for t.select==<br />
The temporal algebra provides a wide range of temporal operators and <br />
functions that will be presented in the following section. <br><br />
<br><br />
<br />
<h3>Temporal relations</h3><br />
<br />
Several temporal topology relations between space <br />
time datasets are supported: <br><br />
<div class="code"><pre><br />
equals A ------<br />
B ------<br />
<br />
during A ---- <br />
B ------<br />
<br />
contains A ------<br />
B ---- <br />
<br />
starts A ----<br />
B ------<br />
<br />
started A ------<br />
B ----<br />
<br />
finishs A ---- <br />
B ------<br />
<br />
finished A ------<br />
B ----<br />
<br />
precedes A ----<br />
B ----<br />
<br />
follows A ----<br />
B ----<br />
<br />
overlapped A ------<br />
B ------<br />
<br />
overlaps A ------<br />
B ------<br />
<br />
over booth overlaps and overlapped<br />
<br />
</pre></div><br />
The relations must be read as: A is related to B, like - A equals B - A is <br />
during B - A contains B <br><br />
<br><br />
Topological relations must be specified in {} parentheses. <br><br />
<br />
<h3>Temporal selection</h3><br />
<br />
The temporal selection simply selects parts of a space time dataset without <br />
processing raster or vector data.<br />
<br />
The algebra provides a selection operator <b>:</b> that selects parts <br />
of a space time dataset that are temporally equal to parts of a second one <br />
by default. The following expression<br />
<div class="code"><pre><br />
C = A : B<br />
</pre></div><br />
means: Select all parts of space time dataset A that are equal to B and store <br />
it in space time dataset C. The parts are in this case time stamped maps. <br><br />
<br><br />
In addition the inverse selection operator <b>!:</b> is defined as the complement of <br />
the selection operator, hence the following expression<br />
<div class="code"><pre><br />
C = A !: B<br />
</pre></div><br />
means: select all parts of space time time dataset A that are not equal to B <br />
and store it in space time dataset (STDS) C. <br><br />
<br><br />
To select parts of a STDS by different topological relations to other STDS, <br />
the temporal topology selection operator can be used. The operator consists of <br />
topological relations, that must be separated by the logical OR operator <br />
<b>||</b> and the temporal selection operator. Both parts are separated by <br />
comma and surrounded by curly braces: <br />
{"topological relations", "temporal selection operator"} <br><br />
<br><br />
Examples:<br />
<div class="code"><pre><br />
C = A {equals,:} B<br />
C = A {equals,!:} B<br />
</pre></div><br />
We can now define arbitrary topological relations using logical OR operator <br />
to connect them:<br />
<div class="code"><pre><br />
C = A {equals||during||overlaps,:} B<br />
</pre></div><br />
Select all parts of A that are equal to B, during B or overlaps B. <br><br />
<br><br />
The selection operator is implicitly contained in the temporal topology <br />
selection operator, so that the following statements are exactly the same:<br />
<div class="code"><pre><br />
C = A : B<br />
C = A {:} B<br />
C = A {equal,:} B<br />
</pre></div><br />
<br />
Same for the complementary selection:<br />
<div class="code"><pre><br />
C = A !: B<br />
C = A {!:} B<br />
C = A {equal,!:} B<br />
</pre></div><br />
<br />
<h3>Conditional statements</h3><br />
<br />
Selection operations can be evaluated within conditional statements.<br />
<br><br />
<div class="code"><pre><br />
Note A and B can either be space time datasets or expressions.<br />
<br />
if statement decision option temporal relations<br />
if(if, then, else)<br />
if(conditions, A) A if conditions are True; temporal topological relation between if and then is equal.<br />
if(conditions, A, B) A if conditions are True, B otherwise; temporal topological relation between if, then and else is equal.<br />
if(topologies, conditions, A) A if conditions are True; temporal topological relation between if and then is explicit specified by topologies.<br />
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.<br />
</pre></div><br />
The conditions are comparison expressions that are used to evaluate <br />
space time datasets. Specific values of temporal variables are <br />
compared by logical operators and evaluated for each map of the STDS.<br />
<br><br />
<br><br />
The supported logical operators:<br />
<div class="code"><pre><br />
Symbol description<br />
<br />
== equal<br />
!= not equal<br />
> greater than<br />
>= greater than or equal<br />
< less than<br />
<= less than or equal<br />
&& and<br />
|| or<br />
</pre></div><br />
<br />
Temporal functions: <br><br />
<div class="code"><pre><br />
<br />
td(A) Returns a list of time intervals of STDS A<br />
<br />
start_time() Start time as HH::MM:SS<br />
start_date() Start date as yyyy-mm-DD<br />
start_datetime() Start datetime as yyyy-mm-DD HH:MM:SS<br />
end_time() End time as HH:MM:SS<br />
end_date() End date as yyyy-mm-DD<br />
end_datetime() End datetime as yyyy-mm-DD HH:MM<br />
<br />
start_doy() Day of year (doy) from the start time [1 - 366]<br />
start_dow() Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1<br />
start_year() The year of the start time [0 - 9999]<br />
start_month() The month of the start time [1 - 12]<br />
start_week() Week of year of the start time [1 - 54]<br />
start_day() Day of month from the start time [1 - 31]<br />
start_hour() The hour of the start time [0 - 23]<br />
start_minute() The minute of the start time [0 - 59]<br />
start_second() The second of the start time [0 - 59]<br />
end_doy() Day of year (doy) from the end time [1 - 366]<br />
end_dow() Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1<br />
end_year() The year of the end time [0 - 9999]<br />
end_month() The month of the end time [1 - 12]<br />
end_week() Week of year of the end time [1 - 54]<br />
end_day() Day of month from the start time [1 - 31]<br />
end_hour() The hour of the end time [0 - 23]<br />
end_minute() The minute of the end time [0 - 59]<br />
end_second() The second of the end time [0 - 59] <br />
</pre></div><br />
<br />
Additionally the number of maps in intervals can be computed and <br />
used in conditional statements. <br><br />
The operator to count the number of maps <br />
is the hash <b>#</b>. <br />
<div class="code"><pre><br />
A{contains,#}B<br />
</pre></div><br />
This expression computes the number of maps from space <br />
time dataset B which are during the time intervals of maps from <br />
space time dataset A.<br><br />
A list of integers (scalars) corresponding to the maps of A <br />
that contain maps from B will be returned. <br><br />
<br><br />
<br />
Furthermore the temporal algebra allows temporal buffering, shifting <br />
and snapping with the functions buff_t(), tshift() and tsnap()<br />
respectively.<br />
<div class="code"><pre><br />
buff_t(A, size) Buffer STDS A with granule ("1 month" or 5)<br />
tshift(A, size) Shift STDS A with granule ("1 month" or 5)<br />
tsnap(A) Snap time instances and intervals of STDS A<br />
</pre></div><br />
<br />
<h3>Examples</h3><br />
<br />
Select all maps from space time dataset A which have equal time stamps <br />
with space time dataset B and C and are ealier that Jan. 1. 2005 and <br />
store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(start_date() < "2005-01-01", A : B : C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset A which contains more than three<br />
maps of space time dataset B, else select maps from C with time<br />
stamps that are not equal to A and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(A {contain, #} B > 3, A {contain, :} B, C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset B which are during the temporal <br />
buffered space time dataset A with a map interval of three days, else<br />
select maps from C and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(contain, td(buff_t(A, "1 days")) == 3, B, C)<br />
</pre></div><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || {{done}}<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || {{done}}<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || {{done}}<br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || {{done}}<br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| {{done}}<br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || in progress<br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || in progress<br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || in progress<br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || in progress<br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
== Week 9 - 2012-07-26 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented functions for temporal operators into the temporal algebra.<br />
* Finsihed the module t.select.<br />
* Wrote the manual page for t.select.<br />
* Started to implement vector operations into the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue documentation of the GRASS module t.select and the integration of the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 10 - 2012-08-02 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Fixed bugs in the temporal algebra.<br />
* More testing of the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the integration of the vector operations into the temporal vector algebra and write documentation and tests.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 11 - 2012-08-09 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Finished implementation of vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Integrated a new function to evaluate spatio-temporal operators with PLY.<br />
* Worked on a lot minor fixes and tests.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Finish the the temporal vector algebra and write documentation. Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 12 - 2012-08-16 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Integrated buffer function into temporal vector algebra.<br />
* Finished temporal vector algebra. <br />
* Worked on documentation and examples for the temporal vector algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write documentation and start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I travelled to Estonia for my PhD thesis, so I had limited time for my project.<br />
<br />
<br />
== Week 13 - 2012-08-23 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Write tests and documentation for the temporal vector algebra.<br />
* Fixed a lot of bugs in the temporal vector algebra.<br />
* Worked on examples for the temporal vector algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I was still busy with the temporal vector algebra this week. Some difficult and time intensive bugs prevent me from starting with the raster algebra.<br />
<br />
== Week 14 - 2012-08-30 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed some more bugs in the temporal vector algebra.<br />
* Made some improvements to speed up the meta data analysis.<br />
* Finished the temporal vector algebra.<br />
* Started with the temporal raster algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occurred<br />
<br />
== Week 15 - 2012-09-06 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Worked on the temporal raster algebra.<br />
* Implemented the lexical analysis for expressions.<br />
* Added arithmetic operations to the temporal raster algebra.<br />
* Rearrange the command list to work with r.mapcalc expression strings.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Occurring problems could be solved.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19686GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-09-06T14:07:44Z<p>Mastho: /* Project plan */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= t.select =<br />
<br />
== Description ==<br />
t.select performs selection of maps that are registered in space time datasets using temporal algebra.<br />
<br />
== Program Use ==<br />
The module expects an <b>expression</b> as input parameter in the following form: <br><br />
<br><br />
<b> "result = expression" </b><br />
<br><br />
<br><br />
<br />
The statement structure is similar to r.mapcalc.<br />
Where <b>result</b> represents the name of a space time dataset (STDS)that will <br />
contain the result of the calculation that is given as <b>expression</b> <br />
on the right side of the equality sign. <br />
These expression can be any valid or nested combination of temporal <br />
operations and functions that are provided by the temporal algebra. <br><br />
The temporal algebra works with space time datasets of any type (STRDS, STR3DS and STVDS). <br />
The algebra provides methods for map selection from STDS based on their temporal relations. <br />
It is also possible to temporally shift maps, to create temporal buffer and to snap time <br />
instances to create a valid temporal topology. Furthermore expressions can be nested and <br />
evaluated in conditional statements (if, else statements). Within if-statements the algebra <br />
provides temporal variables like start time, end time, day of year, time differences or <br />
number of maps per time interval to build up conditions. These operations can be assigned <br />
to space time datasets or to the results of operations between space time datasets. <br />
<br><br />
<br><br />
The type of the input space time datasets must be defined with the input <br />
parameter <b>type</b>. Possible options are STRDS, STVDS or STR3DS. <br />
The default is set to space time raster datasets (STRDS).<br />
<br><br />
<br><br />
As default, topological relationships between space time datasets will be <br />
evaluated only temporal. Use the <b>s</b> flag to activate the <br />
additionally spatial topology evaluation.<br />
<br><br />
<br><br />
The expression option must be passed as <b>quoted</b> <br />
expression, for example: <br><br />
<div class="code"><pre>t.select expression="C = A : B"</pre></div> <br />
Where <b>C</b> is the new space time raster dataset that will contain maps<br />
from <b>A</b> that are selected by equal temporal relationships <br />
to the existing dataset <b>B</b> in this case. <br><br />
<br><br />
<br />
== Temporal Algebra for t.select==<br />
The temporal algebra provides a wide range of temporal operators and <br />
functions that will be presented in the following section. <br><br />
<br><br />
<br />
<h3>Temporal relations</h3><br />
<br />
Several temporal topology relations between space <br />
time datasets are supported: <br><br />
<div class="code"><pre><br />
equals A ------<br />
B ------<br />
<br />
during A ---- <br />
B ------<br />
<br />
contains A ------<br />
B ---- <br />
<br />
starts A ----<br />
B ------<br />
<br />
started A ------<br />
B ----<br />
<br />
finishs A ---- <br />
B ------<br />
<br />
finished A ------<br />
B ----<br />
<br />
precedes A ----<br />
B ----<br />
<br />
follows A ----<br />
B ----<br />
<br />
overlapped A ------<br />
B ------<br />
<br />
overlaps A ------<br />
B ------<br />
<br />
over booth overlaps and overlapped<br />
<br />
</pre></div><br />
The relations must be read as: A is related to B, like - A equals B - A is <br />
during B - A contains B <br><br />
<br><br />
Topological relations must be specified in {} parentheses. <br><br />
<br />
<h3>Temporal selection</h3><br />
<br />
The temporal selection simply selects parts of a space time dataset without <br />
processing raster or vector data.<br />
<br />
The algebra provides a selection operator <b>:</b> that selects parts <br />
of a space time dataset that are temporally equal to parts of a second one <br />
by default. The following expression<br />
<div class="code"><pre><br />
C = A : B<br />
</pre></div><br />
means: Select all parts of space time dataset A that are equal to B and store <br />
it in space time dataset C. The parts are in this case time stamped maps. <br><br />
<br><br />
In addition the inverse selection operator <b>!:</b> is defined as the complement of <br />
the selection operator, hence the following expression<br />
<div class="code"><pre><br />
C = A !: B<br />
</pre></div><br />
means: select all parts of space time time dataset A that are not equal to B <br />
and store it in space time dataset (STDS) C. <br><br />
<br><br />
To select parts of a STDS by different topological relations to other STDS, <br />
the temporal topology selection operator can be used. The operator consists of <br />
topological relations, that must be separated by the logical OR operator <br />
<b>||</b> and the temporal selection operator. Both parts are separated by <br />
comma and surrounded by curly braces: <br />
{"topological relations", "temporal selection operator"} <br><br />
<br><br />
Examples:<br />
<div class="code"><pre><br />
C = A {equals,:} B<br />
C = A {equals,!:} B<br />
</pre></div><br />
We can now define arbitrary topological relations using logical OR operator <br />
to connect them:<br />
<div class="code"><pre><br />
C = A {equals||during||overlaps,:} B<br />
</pre></div><br />
Select all parts of A that are equal to B, during B or overlaps B. <br><br />
<br><br />
The selection operator is implicitly contained in the temporal topology <br />
selection operator, so that the following statements are exactly the same:<br />
<div class="code"><pre><br />
C = A : B<br />
C = A {:} B<br />
C = A {equal,:} B<br />
</pre></div><br />
<br />
Same for the complementary selection:<br />
<div class="code"><pre><br />
C = A !: B<br />
C = A {!:} B<br />
C = A {equal,!:} B<br />
</pre></div><br />
<br />
<h3>Conditional statements</h3><br />
<br />
Selection operations can be evaluated within conditional statements.<br />
<br><br />
<div class="code"><pre><br />
Note A and B can either be space time datasets or expressions.<br />
<br />
if statement decision option temporal relations<br />
if(if, then, else)<br />
if(conditions, A) A if conditions are True; temporal topological relation between if and then is equal.<br />
if(conditions, A, B) A if conditions are True, B otherwise; temporal topological relation between if, then and else is equal.<br />
if(topologies, conditions, A) A if conditions are True; temporal topological relation between if and then is explicit specified by topologies.<br />
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.<br />
</pre></div><br />
The conditions are comparison expressions that are used to evaluate <br />
space time datasets. Specific values of temporal variables are <br />
compared by logical operators and evaluated for each map of the STDS.<br />
<br><br />
<br><br />
The supported logical operators:<br />
<div class="code"><pre><br />
Symbol description<br />
<br />
== equal<br />
!= not equal<br />
> greater than<br />
>= greater than or equal<br />
< less than<br />
<= less than or equal<br />
&& and<br />
|| or<br />
</pre></div><br />
<br />
Temporal functions: <br><br />
<div class="code"><pre><br />
<br />
td(A) Returns a list of time intervals of STDS A<br />
<br />
start_time() Start time as HH::MM:SS<br />
start_date() Start date as yyyy-mm-DD<br />
start_datetime() Start datetime as yyyy-mm-DD HH:MM:SS<br />
end_time() End time as HH:MM:SS<br />
end_date() End date as yyyy-mm-DD<br />
end_datetime() End datetime as yyyy-mm-DD HH:MM<br />
<br />
start_doy() Day of year (doy) from the start time [1 - 366]<br />
start_dow() Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1<br />
start_year() The year of the start time [0 - 9999]<br />
start_month() The month of the start time [1 - 12]<br />
start_week() Week of year of the start time [1 - 54]<br />
start_day() Day of month from the start time [1 - 31]<br />
start_hour() The hour of the start time [0 - 23]<br />
start_minute() The minute of the start time [0 - 59]<br />
start_second() The second of the start time [0 - 59]<br />
end_doy() Day of year (doy) from the end time [1 - 366]<br />
end_dow() Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1<br />
end_year() The year of the end time [0 - 9999]<br />
end_month() The month of the end time [1 - 12]<br />
end_week() Week of year of the end time [1 - 54]<br />
end_day() Day of month from the start time [1 - 31]<br />
end_hour() The hour of the end time [0 - 23]<br />
end_minute() The minute of the end time [0 - 59]<br />
end_second() The second of the end time [0 - 59] <br />
</pre></div><br />
<br />
Additionally the number of maps in intervals can be computed and <br />
used in conditional statements. <br><br />
The operator to count the number of maps <br />
is the hash <b>#</b>. <br />
<div class="code"><pre><br />
A{contains,#}B<br />
</pre></div><br />
This expression computes the number of maps from space <br />
time dataset B which are during the time intervals of maps from <br />
space time dataset A.<br><br />
A list of integers (scalars) corresponding to the maps of A <br />
that contain maps from B will be returned. <br><br />
<br><br />
<br />
Furthermore the temporal algebra allows temporal buffering, shifting <br />
and snapping with the functions buff_t(), tshift() and tsnap()<br />
respectively.<br />
<div class="code"><pre><br />
buff_t(A, size) Buffer STDS A with granule ("1 month" or 5)<br />
tshift(A, size) Shift STDS A with granule ("1 month" or 5)<br />
tsnap(A) Snap time instances and intervals of STDS A<br />
</pre></div><br />
<br />
<h3>Examples</h3><br />
<br />
Select all maps from space time dataset A which have equal time stamps <br />
with space time dataset B and C and are ealier that Jan. 1. 2005 and <br />
store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(start_date() < "2005-01-01", A : B : C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset A which contains more than three<br />
maps of space time dataset B, else select maps from C with time<br />
stamps that are not equal to A and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(A {contain, #} B > 3, A {contain, :} B, C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset B which are during the temporal <br />
buffered space time dataset A with a map interval of three days, else<br />
select maps from C and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(contain, td(buff_t(A, "1 days")) == 3, B, C)<br />
</pre></div><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || {{done}}<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || {{done}}<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || {{done}}<br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || {{done}}<br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| {{done}}<br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || in progress<br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || in progress<br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || in progress<br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || in progress<br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
== Week 9 - 2012-07-26 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented functions for temporal operators into the temporal algebra.<br />
* Finsihed the module t.select.<br />
* Wrote the manual page for t.select.<br />
* Started to implement vector operations into the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue documentation of the GRASS module t.select and the integration of the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 10 - 2012-08-02 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Fixed bugs in the temporal algebra.<br />
* More testing of the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the integration of the vector operations into the temporal vector algebra and write documentation and tests.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 11 - 2012-08-09 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Finished implementation of vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Integrated a new function to evaluate spatio-temporal operators with PLY.<br />
* Worked on a lot minor fixes and tests.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Finish the the temporal vector algebra and write documentation. Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 12 - 2012-08-16 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Integrated buffer function into temporal vector algebra.<br />
* Finished temporal vector algebra. <br />
* Worked on documentation and examples for the temporal vector algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write documentation and start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I travelled to Estonia for my PhD thesis, so I had limited time for my project.<br />
<br />
<br />
== Week 13 - 2012-08-23 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Write tests and documentation for the temporal vector algebra.<br />
* Fixed a lot of bugs in the temporal vector algebra.<br />
* Worked on examples for the temporal vector algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I was still busy with the temporal vector algebra this week. Some difficult and time intensive bugs prevent me from starting with the raster algebra.<br />
<br />
== Week 14 - 2012-08-30 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed some more bugs in the temporal vector algebra.<br />
* Made some improvements to speed up the meta data analysis.<br />
* Finished the temporal vector algebra.<br />
* Started with the temporal raster algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occurred,<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19663GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-08-30T14:38:07Z<p>Mastho: /* Weekly Reports */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= t.select =<br />
<br />
== Description ==<br />
t.select performs selection of maps that are registered in space time datasets using temporal algebra.<br />
<br />
== Program Use ==<br />
The module expects an <b>expression</b> as input parameter in the following form: <br><br />
<br><br />
<b> "result = expression" </b><br />
<br><br />
<br><br />
<br />
The statement structure is similar to r.mapcalc.<br />
Where <b>result</b> represents the name of a space time dataset (STDS)that will <br />
contain the result of the calculation that is given as <b>expression</b> <br />
on the right side of the equality sign. <br />
These expression can be any valid or nested combination of temporal <br />
operations and functions that are provided by the temporal algebra. <br><br />
The temporal algebra works with space time datasets of any type (STRDS, STR3DS and STVDS). <br />
The algebra provides methods for map selection from STDS based on their temporal relations. <br />
It is also possible to temporally shift maps, to create temporal buffer and to snap time <br />
instances to create a valid temporal topology. Furthermore expressions can be nested and <br />
evaluated in conditional statements (if, else statements). Within if-statements the algebra <br />
provides temporal variables like start time, end time, day of year, time differences or <br />
number of maps per time interval to build up conditions. These operations can be assigned <br />
to space time datasets or to the results of operations between space time datasets. <br />
<br><br />
<br><br />
The type of the input space time datasets must be defined with the input <br />
parameter <b>type</b>. Possible options are STRDS, STVDS or STR3DS. <br />
The default is set to space time raster datasets (STRDS).<br />
<br><br />
<br><br />
As default, topological relationships between space time datasets will be <br />
evaluated only temporal. Use the <b>s</b> flag to activate the <br />
additionally spatial topology evaluation.<br />
<br><br />
<br><br />
The expression option must be passed as <b>quoted</b> <br />
expression, for example: <br><br />
<div class="code"><pre>t.select expression="C = A : B"</pre></div> <br />
Where <b>C</b> is the new space time raster dataset that will contain maps<br />
from <b>A</b> that are selected by equal temporal relationships <br />
to the existing dataset <b>B</b> in this case. <br><br />
<br><br />
<br />
== Temporal Algebra for t.select==<br />
The temporal algebra provides a wide range of temporal operators and <br />
functions that will be presented in the following section. <br><br />
<br><br />
<br />
<h3>Temporal relations</h3><br />
<br />
Several temporal topology relations between space <br />
time datasets are supported: <br><br />
<div class="code"><pre><br />
equals A ------<br />
B ------<br />
<br />
during A ---- <br />
B ------<br />
<br />
contains A ------<br />
B ---- <br />
<br />
starts A ----<br />
B ------<br />
<br />
started A ------<br />
B ----<br />
<br />
finishs A ---- <br />
B ------<br />
<br />
finished A ------<br />
B ----<br />
<br />
precedes A ----<br />
B ----<br />
<br />
follows A ----<br />
B ----<br />
<br />
overlapped A ------<br />
B ------<br />
<br />
overlaps A ------<br />
B ------<br />
<br />
over booth overlaps and overlapped<br />
<br />
</pre></div><br />
The relations must be read as: A is related to B, like - A equals B - A is <br />
during B - A contains B <br><br />
<br><br />
Topological relations must be specified in {} parentheses. <br><br />
<br />
<h3>Temporal selection</h3><br />
<br />
The temporal selection simply selects parts of a space time dataset without <br />
processing raster or vector data.<br />
<br />
The algebra provides a selection operator <b>:</b> that selects parts <br />
of a space time dataset that are temporally equal to parts of a second one <br />
by default. The following expression<br />
<div class="code"><pre><br />
C = A : B<br />
</pre></div><br />
means: Select all parts of space time dataset A that are equal to B and store <br />
it in space time dataset C. The parts are in this case time stamped maps. <br><br />
<br><br />
In addition the inverse selection operator <b>!:</b> is defined as the complement of <br />
the selection operator, hence the following expression<br />
<div class="code"><pre><br />
C = A !: B<br />
</pre></div><br />
means: select all parts of space time time dataset A that are not equal to B <br />
and store it in space time dataset (STDS) C. <br><br />
<br><br />
To select parts of a STDS by different topological relations to other STDS, <br />
the temporal topology selection operator can be used. The operator consists of <br />
topological relations, that must be separated by the logical OR operator <br />
<b>||</b> and the temporal selection operator. Both parts are separated by <br />
comma and surrounded by curly braces: <br />
{"topological relations", "temporal selection operator"} <br><br />
<br><br />
Examples:<br />
<div class="code"><pre><br />
C = A {equals,:} B<br />
C = A {equals,!:} B<br />
</pre></div><br />
We can now define arbitrary topological relations using logical OR operator <br />
to connect them:<br />
<div class="code"><pre><br />
C = A {equals||during||overlaps,:} B<br />
</pre></div><br />
Select all parts of A that are equal to B, during B or overlaps B. <br><br />
<br><br />
The selection operator is implicitly contained in the temporal topology <br />
selection operator, so that the following statements are exactly the same:<br />
<div class="code"><pre><br />
C = A : B<br />
C = A {:} B<br />
C = A {equal,:} B<br />
</pre></div><br />
<br />
Same for the complementary selection:<br />
<div class="code"><pre><br />
C = A !: B<br />
C = A {!:} B<br />
C = A {equal,!:} B<br />
</pre></div><br />
<br />
<h3>Conditional statements</h3><br />
<br />
Selection operations can be evaluated within conditional statements.<br />
<br><br />
<div class="code"><pre><br />
Note A and B can either be space time datasets or expressions.<br />
<br />
if statement decision option temporal relations<br />
if(if, then, else)<br />
if(conditions, A) A if conditions are True; temporal topological relation between if and then is equal.<br />
if(conditions, A, B) A if conditions are True, B otherwise; temporal topological relation between if, then and else is equal.<br />
if(topologies, conditions, A) A if conditions are True; temporal topological relation between if and then is explicit specified by topologies.<br />
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.<br />
</pre></div><br />
The conditions are comparison expressions that are used to evaluate <br />
space time datasets. Specific values of temporal variables are <br />
compared by logical operators and evaluated for each map of the STDS.<br />
<br><br />
<br><br />
The supported logical operators:<br />
<div class="code"><pre><br />
Symbol description<br />
<br />
== equal<br />
!= not equal<br />
> greater than<br />
>= greater than or equal<br />
< less than<br />
<= less than or equal<br />
&& and<br />
|| or<br />
</pre></div><br />
<br />
Temporal functions: <br><br />
<div class="code"><pre><br />
<br />
td(A) Returns a list of time intervals of STDS A<br />
<br />
start_time() Start time as HH::MM:SS<br />
start_date() Start date as yyyy-mm-DD<br />
start_datetime() Start datetime as yyyy-mm-DD HH:MM:SS<br />
end_time() End time as HH:MM:SS<br />
end_date() End date as yyyy-mm-DD<br />
end_datetime() End datetime as yyyy-mm-DD HH:MM<br />
<br />
start_doy() Day of year (doy) from the start time [1 - 366]<br />
start_dow() Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1<br />
start_year() The year of the start time [0 - 9999]<br />
start_month() The month of the start time [1 - 12]<br />
start_week() Week of year of the start time [1 - 54]<br />
start_day() Day of month from the start time [1 - 31]<br />
start_hour() The hour of the start time [0 - 23]<br />
start_minute() The minute of the start time [0 - 59]<br />
start_second() The second of the start time [0 - 59]<br />
end_doy() Day of year (doy) from the end time [1 - 366]<br />
end_dow() Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1<br />
end_year() The year of the end time [0 - 9999]<br />
end_month() The month of the end time [1 - 12]<br />
end_week() Week of year of the end time [1 - 54]<br />
end_day() Day of month from the start time [1 - 31]<br />
end_hour() The hour of the end time [0 - 23]<br />
end_minute() The minute of the end time [0 - 59]<br />
end_second() The second of the end time [0 - 59] <br />
</pre></div><br />
<br />
Additionally the number of maps in intervals can be computed and <br />
used in conditional statements. <br><br />
The operator to count the number of maps <br />
is the hash <b>#</b>. <br />
<div class="code"><pre><br />
A{contains,#}B<br />
</pre></div><br />
This expression computes the number of maps from space <br />
time dataset B which are during the time intervals of maps from <br />
space time dataset A.<br><br />
A list of integers (scalars) corresponding to the maps of A <br />
that contain maps from B will be returned. <br><br />
<br><br />
<br />
Furthermore the temporal algebra allows temporal buffering, shifting <br />
and snapping with the functions buff_t(), tshift() and tsnap()<br />
respectively.<br />
<div class="code"><pre><br />
buff_t(A, size) Buffer STDS A with granule ("1 month" or 5)<br />
tshift(A, size) Shift STDS A with granule ("1 month" or 5)<br />
tsnap(A) Snap time instances and intervals of STDS A<br />
</pre></div><br />
<br />
<h3>Examples</h3><br />
<br />
Select all maps from space time dataset A which have equal time stamps <br />
with space time dataset B and C and are ealier that Jan. 1. 2005 and <br />
store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(start_date() < "2005-01-01", A : B : C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset A which contains more than three<br />
maps of space time dataset B, else select maps from C with time<br />
stamps that are not equal to A and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(A {contain, #} B > 3, A {contain, :} B, C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset B which are during the temporal <br />
buffered space time dataset A with a map interval of three days, else<br />
select maps from C and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(contain, td(buff_t(A, "1 days")) == 3, B, C)<br />
</pre></div><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || {{done}}<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || {{done}}<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || {{done}}<br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || {{done}}<br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| in progress<br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
== Week 9 - 2012-07-26 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented functions for temporal operators into the temporal algebra.<br />
* Finsihed the module t.select.<br />
* Wrote the manual page for t.select.<br />
* Started to implement vector operations into the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue documentation of the GRASS module t.select and the integration of the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 10 - 2012-08-02 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Fixed bugs in the temporal algebra.<br />
* More testing of the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the integration of the vector operations into the temporal vector algebra and write documentation and tests.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 11 - 2012-08-09 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Finished implementation of vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Integrated a new function to evaluate spatio-temporal operators with PLY.<br />
* Worked on a lot minor fixes and tests.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Finish the the temporal vector algebra and write documentation. Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 12 - 2012-08-16 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Integrated buffer function into temporal vector algebra.<br />
* Finished temporal vector algebra. <br />
* Worked on documentation and examples for the temporal vector algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write documentation and start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I travelled to Estonia for my PhD thesis, so I had limited time for my project.<br />
<br />
<br />
== Week 13 - 2012-08-23 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Write tests and documentation for the temporal vector algebra.<br />
* Fixed a lot of bugs in the temporal vector algebra.<br />
* Worked on examples for the temporal vector algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I was still busy with the temporal vector algebra this week. Some difficult and time intensive bugs prevent me from starting with the raster algebra.<br />
<br />
== Week 14 - 2012-08-30 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed some more bugs in the temporal vector algebra.<br />
* Made some improvements to speed up the meta data analysis.<br />
* Finished the temporal vector algebra.<br />
* Started with the temporal raster algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occurred,<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19653GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-08-23T17:08:06Z<p>Mastho: /* Weekly Reports */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= t.select =<br />
<br />
== Description ==<br />
t.select performs selection of maps that are registered in space time datasets using temporal algebra.<br />
<br />
== Program Use ==<br />
The module expects an <b>expression</b> as input parameter in the following form: <br><br />
<br><br />
<b> "result = expression" </b><br />
<br><br />
<br><br />
<br />
The statement structure is similar to r.mapcalc.<br />
Where <b>result</b> represents the name of a space time dataset (STDS)that will <br />
contain the result of the calculation that is given as <b>expression</b> <br />
on the right side of the equality sign. <br />
These expression can be any valid or nested combination of temporal <br />
operations and functions that are provided by the temporal algebra. <br><br />
The temporal algebra works with space time datasets of any type (STRDS, STR3DS and STVDS). <br />
The algebra provides methods for map selection from STDS based on their temporal relations. <br />
It is also possible to temporally shift maps, to create temporal buffer and to snap time <br />
instances to create a valid temporal topology. Furthermore expressions can be nested and <br />
evaluated in conditional statements (if, else statements). Within if-statements the algebra <br />
provides temporal variables like start time, end time, day of year, time differences or <br />
number of maps per time interval to build up conditions. These operations can be assigned <br />
to space time datasets or to the results of operations between space time datasets. <br />
<br><br />
<br><br />
The type of the input space time datasets must be defined with the input <br />
parameter <b>type</b>. Possible options are STRDS, STVDS or STR3DS. <br />
The default is set to space time raster datasets (STRDS).<br />
<br><br />
<br><br />
As default, topological relationships between space time datasets will be <br />
evaluated only temporal. Use the <b>s</b> flag to activate the <br />
additionally spatial topology evaluation.<br />
<br><br />
<br><br />
The expression option must be passed as <b>quoted</b> <br />
expression, for example: <br><br />
<div class="code"><pre>t.select expression="C = A : B"</pre></div> <br />
Where <b>C</b> is the new space time raster dataset that will contain maps<br />
from <b>A</b> that are selected by equal temporal relationships <br />
to the existing dataset <b>B</b> in this case. <br><br />
<br><br />
<br />
== Temporal Algebra for t.select==<br />
The temporal algebra provides a wide range of temporal operators and <br />
functions that will be presented in the following section. <br><br />
<br><br />
<br />
<h3>Temporal relations</h3><br />
<br />
Several temporal topology relations between space <br />
time datasets are supported: <br><br />
<div class="code"><pre><br />
equals A ------<br />
B ------<br />
<br />
during A ---- <br />
B ------<br />
<br />
contains A ------<br />
B ---- <br />
<br />
starts A ----<br />
B ------<br />
<br />
started A ------<br />
B ----<br />
<br />
finishs A ---- <br />
B ------<br />
<br />
finished A ------<br />
B ----<br />
<br />
precedes A ----<br />
B ----<br />
<br />
follows A ----<br />
B ----<br />
<br />
overlapped A ------<br />
B ------<br />
<br />
overlaps A ------<br />
B ------<br />
<br />
over booth overlaps and overlapped<br />
<br />
</pre></div><br />
The relations must be read as: A is related to B, like - A equals B - A is <br />
during B - A contains B <br><br />
<br><br />
Topological relations must be specified in {} parentheses. <br><br />
<br />
<h3>Temporal selection</h3><br />
<br />
The temporal selection simply selects parts of a space time dataset without <br />
processing raster or vector data.<br />
<br />
The algebra provides a selection operator <b>:</b> that selects parts <br />
of a space time dataset that are temporally equal to parts of a second one <br />
by default. The following expression<br />
<div class="code"><pre><br />
C = A : B<br />
</pre></div><br />
means: Select all parts of space time dataset A that are equal to B and store <br />
it in space time dataset C. The parts are in this case time stamped maps. <br><br />
<br><br />
In addition the inverse selection operator <b>!:</b> is defined as the complement of <br />
the selection operator, hence the following expression<br />
<div class="code"><pre><br />
C = A !: B<br />
</pre></div><br />
means: select all parts of space time time dataset A that are not equal to B <br />
and store it in space time dataset (STDS) C. <br><br />
<br><br />
To select parts of a STDS by different topological relations to other STDS, <br />
the temporal topology selection operator can be used. The operator consists of <br />
topological relations, that must be separated by the logical OR operator <br />
<b>||</b> and the temporal selection operator. Both parts are separated by <br />
comma and surrounded by curly braces: <br />
{"topological relations", "temporal selection operator"} <br><br />
<br><br />
Examples:<br />
<div class="code"><pre><br />
C = A {equals,:} B<br />
C = A {equals,!:} B<br />
</pre></div><br />
We can now define arbitrary topological relations using logical OR operator <br />
to connect them:<br />
<div class="code"><pre><br />
C = A {equals||during||overlaps,:} B<br />
</pre></div><br />
Select all parts of A that are equal to B, during B or overlaps B. <br><br />
<br><br />
The selection operator is implicitly contained in the temporal topology <br />
selection operator, so that the following statements are exactly the same:<br />
<div class="code"><pre><br />
C = A : B<br />
C = A {:} B<br />
C = A {equal,:} B<br />
</pre></div><br />
<br />
Same for the complementary selection:<br />
<div class="code"><pre><br />
C = A !: B<br />
C = A {!:} B<br />
C = A {equal,!:} B<br />
</pre></div><br />
<br />
<h3>Conditional statements</h3><br />
<br />
Selection operations can be evaluated within conditional statements.<br />
<br><br />
<div class="code"><pre><br />
Note A and B can either be space time datasets or expressions.<br />
<br />
if statement decision option temporal relations<br />
if(if, then, else)<br />
if(conditions, A) A if conditions are True; temporal topological relation between if and then is equal.<br />
if(conditions, A, B) A if conditions are True, B otherwise; temporal topological relation between if, then and else is equal.<br />
if(topologies, conditions, A) A if conditions are True; temporal topological relation between if and then is explicit specified by topologies.<br />
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.<br />
</pre></div><br />
The conditions are comparison expressions that are used to evaluate <br />
space time datasets. Specific values of temporal variables are <br />
compared by logical operators and evaluated for each map of the STDS.<br />
<br><br />
<br><br />
The supported logical operators:<br />
<div class="code"><pre><br />
Symbol description<br />
<br />
== equal<br />
!= not equal<br />
> greater than<br />
>= greater than or equal<br />
< less than<br />
<= less than or equal<br />
&& and<br />
|| or<br />
</pre></div><br />
<br />
Temporal functions: <br><br />
<div class="code"><pre><br />
<br />
td(A) Returns a list of time intervals of STDS A<br />
<br />
start_time() Start time as HH::MM:SS<br />
start_date() Start date as yyyy-mm-DD<br />
start_datetime() Start datetime as yyyy-mm-DD HH:MM:SS<br />
end_time() End time as HH:MM:SS<br />
end_date() End date as yyyy-mm-DD<br />
end_datetime() End datetime as yyyy-mm-DD HH:MM<br />
<br />
start_doy() Day of year (doy) from the start time [1 - 366]<br />
start_dow() Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1<br />
start_year() The year of the start time [0 - 9999]<br />
start_month() The month of the start time [1 - 12]<br />
start_week() Week of year of the start time [1 - 54]<br />
start_day() Day of month from the start time [1 - 31]<br />
start_hour() The hour of the start time [0 - 23]<br />
start_minute() The minute of the start time [0 - 59]<br />
start_second() The second of the start time [0 - 59]<br />
end_doy() Day of year (doy) from the end time [1 - 366]<br />
end_dow() Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1<br />
end_year() The year of the end time [0 - 9999]<br />
end_month() The month of the end time [1 - 12]<br />
end_week() Week of year of the end time [1 - 54]<br />
end_day() Day of month from the start time [1 - 31]<br />
end_hour() The hour of the end time [0 - 23]<br />
end_minute() The minute of the end time [0 - 59]<br />
end_second() The second of the end time [0 - 59] <br />
</pre></div><br />
<br />
Additionally the number of maps in intervals can be computed and <br />
used in conditional statements. <br><br />
The operator to count the number of maps <br />
is the hash <b>#</b>. <br />
<div class="code"><pre><br />
A{contains,#}B<br />
</pre></div><br />
This expression computes the number of maps from space <br />
time dataset B which are during the time intervals of maps from <br />
space time dataset A.<br><br />
A list of integers (scalars) corresponding to the maps of A <br />
that contain maps from B will be returned. <br><br />
<br><br />
<br />
Furthermore the temporal algebra allows temporal buffering, shifting <br />
and snapping with the functions buff_t(), tshift() and tsnap()<br />
respectively.<br />
<div class="code"><pre><br />
buff_t(A, size) Buffer STDS A with granule ("1 month" or 5)<br />
tshift(A, size) Shift STDS A with granule ("1 month" or 5)<br />
tsnap(A) Snap time instances and intervals of STDS A<br />
</pre></div><br />
<br />
<h3>Examples</h3><br />
<br />
Select all maps from space time dataset A which have equal time stamps <br />
with space time dataset B and C and are ealier that Jan. 1. 2005 and <br />
store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(start_date() < "2005-01-01", A : B : C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset A which contains more than three<br />
maps of space time dataset B, else select maps from C with time<br />
stamps that are not equal to A and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(A {contain, #} B > 3, A {contain, :} B, C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset B which are during the temporal <br />
buffered space time dataset A with a map interval of three days, else<br />
select maps from C and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(contain, td(buff_t(A, "1 days")) == 3, B, C)<br />
</pre></div><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || {{done}}<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || {{done}}<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || {{done}}<br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || {{done}}<br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| in progress<br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
== Week 9 - 2012-07-26 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented functions for temporal operators into the temporal algebra.<br />
* Finsihed the module t.select.<br />
* Wrote the manual page for t.select.<br />
* Started to implement vector operations into the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue documentation of the GRASS module t.select and the integration of the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 10 - 2012-08-02 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Fixed bugs in the temporal algebra.<br />
* More testing of the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the integration of the vector operations into the temporal vector algebra and write documentation and tests.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 11 - 2012-08-09 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Finished implementation of vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Integrated a new function to evaluate spatio-temporal operators with PLY.<br />
* Worked on a lot minor fixes and tests.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Finish the the temporal vector algebra and write documentation. Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 12 - 2012-08-16 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Integrated buffer function into temporal vector algebra.<br />
* Finished temporal vector algebra. <br />
* Worked on documentation and examples for the temporal vector algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write documentation and start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I travelled to Estonia for my PhD thesis, so I had limited time for my project.<br />
<br />
<br />
== Week 13 - 2012-08-23 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Write tests and documentation for the temporal vector algebra.<br />
* Fixed a lot of bugs in the temporal vector algebra.<br />
* Worked on examples for the temporal vector algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I was still busy with the temporal vector algebra this week. Some difficult and time intensive bugs prevent me from starting with the raster algebra.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19651GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-08-20T07:01:16Z<p>Mastho: /* Weekly Reports */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= t.select =<br />
<br />
== Description ==<br />
t.select performs selection of maps that are registered in space time datasets using temporal algebra.<br />
<br />
== Program Use ==<br />
The module expects an <b>expression</b> as input parameter in the following form: <br><br />
<br><br />
<b> "result = expression" </b><br />
<br><br />
<br><br />
<br />
The statement structure is similar to r.mapcalc.<br />
Where <b>result</b> represents the name of a space time dataset (STDS)that will <br />
contain the result of the calculation that is given as <b>expression</b> <br />
on the right side of the equality sign. <br />
These expression can be any valid or nested combination of temporal <br />
operations and functions that are provided by the temporal algebra. <br><br />
The temporal algebra works with space time datasets of any type (STRDS, STR3DS and STVDS). <br />
The algebra provides methods for map selection from STDS based on their temporal relations. <br />
It is also possible to temporally shift maps, to create temporal buffer and to snap time <br />
instances to create a valid temporal topology. Furthermore expressions can be nested and <br />
evaluated in conditional statements (if, else statements). Within if-statements the algebra <br />
provides temporal variables like start time, end time, day of year, time differences or <br />
number of maps per time interval to build up conditions. These operations can be assigned <br />
to space time datasets or to the results of operations between space time datasets. <br />
<br><br />
<br><br />
The type of the input space time datasets must be defined with the input <br />
parameter <b>type</b>. Possible options are STRDS, STVDS or STR3DS. <br />
The default is set to space time raster datasets (STRDS).<br />
<br><br />
<br><br />
As default, topological relationships between space time datasets will be <br />
evaluated only temporal. Use the <b>s</b> flag to activate the <br />
additionally spatial topology evaluation.<br />
<br><br />
<br><br />
The expression option must be passed as <b>quoted</b> <br />
expression, for example: <br><br />
<div class="code"><pre>t.select expression="C = A : B"</pre></div> <br />
Where <b>C</b> is the new space time raster dataset that will contain maps<br />
from <b>A</b> that are selected by equal temporal relationships <br />
to the existing dataset <b>B</b> in this case. <br><br />
<br><br />
<br />
== Temporal Algebra for t.select==<br />
The temporal algebra provides a wide range of temporal operators and <br />
functions that will be presented in the following section. <br><br />
<br><br />
<br />
<h3>Temporal relations</h3><br />
<br />
Several temporal topology relations between space <br />
time datasets are supported: <br><br />
<div class="code"><pre><br />
equals A ------<br />
B ------<br />
<br />
during A ---- <br />
B ------<br />
<br />
contains A ------<br />
B ---- <br />
<br />
starts A ----<br />
B ------<br />
<br />
started A ------<br />
B ----<br />
<br />
finishs A ---- <br />
B ------<br />
<br />
finished A ------<br />
B ----<br />
<br />
precedes A ----<br />
B ----<br />
<br />
follows A ----<br />
B ----<br />
<br />
overlapped A ------<br />
B ------<br />
<br />
overlaps A ------<br />
B ------<br />
<br />
over booth overlaps and overlapped<br />
<br />
</pre></div><br />
The relations must be read as: A is related to B, like - A equals B - A is <br />
during B - A contains B <br><br />
<br><br />
Topological relations must be specified in {} parentheses. <br><br />
<br />
<h3>Temporal selection</h3><br />
<br />
The temporal selection simply selects parts of a space time dataset without <br />
processing raster or vector data.<br />
<br />
The algebra provides a selection operator <b>:</b> that selects parts <br />
of a space time dataset that are temporally equal to parts of a second one <br />
by default. The following expression<br />
<div class="code"><pre><br />
C = A : B<br />
</pre></div><br />
means: Select all parts of space time dataset A that are equal to B and store <br />
it in space time dataset C. The parts are in this case time stamped maps. <br><br />
<br><br />
In addition the inverse selection operator <b>!:</b> is defined as the complement of <br />
the selection operator, hence the following expression<br />
<div class="code"><pre><br />
C = A !: B<br />
</pre></div><br />
means: select all parts of space time time dataset A that are not equal to B <br />
and store it in space time dataset (STDS) C. <br><br />
<br><br />
To select parts of a STDS by different topological relations to other STDS, <br />
the temporal topology selection operator can be used. The operator consists of <br />
topological relations, that must be separated by the logical OR operator <br />
<b>||</b> and the temporal selection operator. Both parts are separated by <br />
comma and surrounded by curly braces: <br />
{"topological relations", "temporal selection operator"} <br><br />
<br><br />
Examples:<br />
<div class="code"><pre><br />
C = A {equals,:} B<br />
C = A {equals,!:} B<br />
</pre></div><br />
We can now define arbitrary topological relations using logical OR operator <br />
to connect them:<br />
<div class="code"><pre><br />
C = A {equals||during||overlaps,:} B<br />
</pre></div><br />
Select all parts of A that are equal to B, during B or overlaps B. <br><br />
<br><br />
The selection operator is implicitly contained in the temporal topology <br />
selection operator, so that the following statements are exactly the same:<br />
<div class="code"><pre><br />
C = A : B<br />
C = A {:} B<br />
C = A {equal,:} B<br />
</pre></div><br />
<br />
Same for the complementary selection:<br />
<div class="code"><pre><br />
C = A !: B<br />
C = A {!:} B<br />
C = A {equal,!:} B<br />
</pre></div><br />
<br />
<h3>Conditional statements</h3><br />
<br />
Selection operations can be evaluated within conditional statements.<br />
<br><br />
<div class="code"><pre><br />
Note A and B can either be space time datasets or expressions.<br />
<br />
if statement decision option temporal relations<br />
if(if, then, else)<br />
if(conditions, A) A if conditions are True; temporal topological relation between if and then is equal.<br />
if(conditions, A, B) A if conditions are True, B otherwise; temporal topological relation between if, then and else is equal.<br />
if(topologies, conditions, A) A if conditions are True; temporal topological relation between if and then is explicit specified by topologies.<br />
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.<br />
</pre></div><br />
The conditions are comparison expressions that are used to evaluate <br />
space time datasets. Specific values of temporal variables are <br />
compared by logical operators and evaluated for each map of the STDS.<br />
<br><br />
<br><br />
The supported logical operators:<br />
<div class="code"><pre><br />
Symbol description<br />
<br />
== equal<br />
!= not equal<br />
> greater than<br />
>= greater than or equal<br />
< less than<br />
<= less than or equal<br />
&& and<br />
|| or<br />
</pre></div><br />
<br />
Temporal functions: <br><br />
<div class="code"><pre><br />
<br />
td(A) Returns a list of time intervals of STDS A<br />
<br />
start_time() Start time as HH::MM:SS<br />
start_date() Start date as yyyy-mm-DD<br />
start_datetime() Start datetime as yyyy-mm-DD HH:MM:SS<br />
end_time() End time as HH:MM:SS<br />
end_date() End date as yyyy-mm-DD<br />
end_datetime() End datetime as yyyy-mm-DD HH:MM<br />
<br />
start_doy() Day of year (doy) from the start time [1 - 366]<br />
start_dow() Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1<br />
start_year() The year of the start time [0 - 9999]<br />
start_month() The month of the start time [1 - 12]<br />
start_week() Week of year of the start time [1 - 54]<br />
start_day() Day of month from the start time [1 - 31]<br />
start_hour() The hour of the start time [0 - 23]<br />
start_minute() The minute of the start time [0 - 59]<br />
start_second() The second of the start time [0 - 59]<br />
end_doy() Day of year (doy) from the end time [1 - 366]<br />
end_dow() Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1<br />
end_year() The year of the end time [0 - 9999]<br />
end_month() The month of the end time [1 - 12]<br />
end_week() Week of year of the end time [1 - 54]<br />
end_day() Day of month from the start time [1 - 31]<br />
end_hour() The hour of the end time [0 - 23]<br />
end_minute() The minute of the end time [0 - 59]<br />
end_second() The second of the end time [0 - 59] <br />
</pre></div><br />
<br />
Additionally the number of maps in intervals can be computed and <br />
used in conditional statements. <br><br />
The operator to count the number of maps <br />
is the hash <b>#</b>. <br />
<div class="code"><pre><br />
A{contains,#}B<br />
</pre></div><br />
This expression computes the number of maps from space <br />
time dataset B which are during the time intervals of maps from <br />
space time dataset A.<br><br />
A list of integers (scalars) corresponding to the maps of A <br />
that contain maps from B will be returned. <br><br />
<br><br />
<br />
Furthermore the temporal algebra allows temporal buffering, shifting <br />
and snapping with the functions buff_t(), tshift() and tsnap()<br />
respectively.<br />
<div class="code"><pre><br />
buff_t(A, size) Buffer STDS A with granule ("1 month" or 5)<br />
tshift(A, size) Shift STDS A with granule ("1 month" or 5)<br />
tsnap(A) Snap time instances and intervals of STDS A<br />
</pre></div><br />
<br />
<h3>Examples</h3><br />
<br />
Select all maps from space time dataset A which have equal time stamps <br />
with space time dataset B and C and are ealier that Jan. 1. 2005 and <br />
store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(start_date() < "2005-01-01", A : B : C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset A which contains more than three<br />
maps of space time dataset B, else select maps from C with time<br />
stamps that are not equal to A and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(A {contain, #} B > 3, A {contain, :} B, C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset B which are during the temporal <br />
buffered space time dataset A with a map interval of three days, else<br />
select maps from C and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(contain, td(buff_t(A, "1 days")) == 3, B, C)<br />
</pre></div><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || {{done}}<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || {{done}}<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || {{done}}<br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || {{done}}<br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| in progress<br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
== Week 9 - 2012-07-26 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented functions for temporal operators into the temporal algebra.<br />
* Finsihed the module t.select.<br />
* Wrote the manual page for t.select.<br />
* Started to implement vector operations into the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue documentation of the GRASS module t.select and the integration of the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 10 - 2012-08-02 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Fixed bugs in the temporal algebra.<br />
* More testing of the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the integration of the vector operations into the temporal vector algebra and write documentation and tests.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 11 - 2012-08-09 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Finished implementation of vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Integrated a new function to evaluate spatio-temporal operators with PLY.<br />
* Worked on a lot minor fixes and tests.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Finish the the temporal vector algebra and write documentation. Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 12 - 2012-08-16 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Integrated buffer function into temporal vector algebra.<br />
* Finished temporal vector algebra. <br />
* Worked on documentation and examples for the temporal vector algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write documentation and start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I travelled to Estonia for my PhD thesis, so I had limited time for my project.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19646GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-08-12T15:25:48Z<p>Mastho: /* Project plan */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= t.select =<br />
<br />
== Description ==<br />
t.select performs selection of maps that are registered in space time datasets using temporal algebra.<br />
<br />
== Program Use ==<br />
The module expects an <b>expression</b> as input parameter in the following form: <br><br />
<br><br />
<b> "result = expression" </b><br />
<br><br />
<br><br />
<br />
The statement structure is similar to r.mapcalc.<br />
Where <b>result</b> represents the name of a space time dataset (STDS)that will <br />
contain the result of the calculation that is given as <b>expression</b> <br />
on the right side of the equality sign. <br />
These expression can be any valid or nested combination of temporal <br />
operations and functions that are provided by the temporal algebra. <br><br />
The temporal algebra works with space time datasets of any type (STRDS, STR3DS and STVDS). <br />
The algebra provides methods for map selection from STDS based on their temporal relations. <br />
It is also possible to temporally shift maps, to create temporal buffer and to snap time <br />
instances to create a valid temporal topology. Furthermore expressions can be nested and <br />
evaluated in conditional statements (if, else statements). Within if-statements the algebra <br />
provides temporal variables like start time, end time, day of year, time differences or <br />
number of maps per time interval to build up conditions. These operations can be assigned <br />
to space time datasets or to the results of operations between space time datasets. <br />
<br><br />
<br><br />
The type of the input space time datasets must be defined with the input <br />
parameter <b>type</b>. Possible options are STRDS, STVDS or STR3DS. <br />
The default is set to space time raster datasets (STRDS).<br />
<br><br />
<br><br />
As default, topological relationships between space time datasets will be <br />
evaluated only temporal. Use the <b>s</b> flag to activate the <br />
additionally spatial topology evaluation.<br />
<br><br />
<br><br />
The expression option must be passed as <b>quoted</b> <br />
expression, for example: <br><br />
<div class="code"><pre>t.select expression="C = A : B"</pre></div> <br />
Where <b>C</b> is the new space time raster dataset that will contain maps<br />
from <b>A</b> that are selected by equal temporal relationships <br />
to the existing dataset <b>B</b> in this case. <br><br />
<br><br />
<br />
== Temporal Algebra for t.select==<br />
The temporal algebra provides a wide range of temporal operators and <br />
functions that will be presented in the following section. <br><br />
<br><br />
<br />
<h3>Temporal relations</h3><br />
<br />
Several temporal topology relations between space <br />
time datasets are supported: <br><br />
<div class="code"><pre><br />
equals A ------<br />
B ------<br />
<br />
during A ---- <br />
B ------<br />
<br />
contains A ------<br />
B ---- <br />
<br />
starts A ----<br />
B ------<br />
<br />
started A ------<br />
B ----<br />
<br />
finishs A ---- <br />
B ------<br />
<br />
finished A ------<br />
B ----<br />
<br />
precedes A ----<br />
B ----<br />
<br />
follows A ----<br />
B ----<br />
<br />
overlapped A ------<br />
B ------<br />
<br />
overlaps A ------<br />
B ------<br />
<br />
over booth overlaps and overlapped<br />
<br />
</pre></div><br />
The relations must be read as: A is related to B, like - A equals B - A is <br />
during B - A contains B <br><br />
<br><br />
Topological relations must be specified in {} parentheses. <br><br />
<br />
<h3>Temporal selection</h3><br />
<br />
The temporal selection simply selects parts of a space time dataset without <br />
processing raster or vector data.<br />
<br />
The algebra provides a selection operator <b>:</b> that selects parts <br />
of a space time dataset that are temporally equal to parts of a second one <br />
by default. The following expression<br />
<div class="code"><pre><br />
C = A : B<br />
</pre></div><br />
means: Select all parts of space time dataset A that are equal to B and store <br />
it in space time dataset C. The parts are in this case time stamped maps. <br><br />
<br><br />
In addition the inverse selection operator <b>!:</b> is defined as the complement of <br />
the selection operator, hence the following expression<br />
<div class="code"><pre><br />
C = A !: B<br />
</pre></div><br />
means: select all parts of space time time dataset A that are not equal to B <br />
and store it in space time dataset (STDS) C. <br><br />
<br><br />
To select parts of a STDS by different topological relations to other STDS, <br />
the temporal topology selection operator can be used. The operator consists of <br />
topological relations, that must be separated by the logical OR operator <br />
<b>||</b> and the temporal selection operator. Both parts are separated by <br />
comma and surrounded by curly braces: <br />
{"topological relations", "temporal selection operator"} <br><br />
<br><br />
Examples:<br />
<div class="code"><pre><br />
C = A {equals,:} B<br />
C = A {equals,!:} B<br />
</pre></div><br />
We can now define arbitrary topological relations using logical OR operator <br />
to connect them:<br />
<div class="code"><pre><br />
C = A {equals||during||overlaps,:} B<br />
</pre></div><br />
Select all parts of A that are equal to B, during B or overlaps B. <br><br />
<br><br />
The selection operator is implicitly contained in the temporal topology <br />
selection operator, so that the following statements are exactly the same:<br />
<div class="code"><pre><br />
C = A : B<br />
C = A {:} B<br />
C = A {equal,:} B<br />
</pre></div><br />
<br />
Same for the complementary selection:<br />
<div class="code"><pre><br />
C = A !: B<br />
C = A {!:} B<br />
C = A {equal,!:} B<br />
</pre></div><br />
<br />
<h3>Conditional statements</h3><br />
<br />
Selection operations can be evaluated within conditional statements.<br />
<br><br />
<div class="code"><pre><br />
Note A and B can either be space time datasets or expressions.<br />
<br />
if statement decision option temporal relations<br />
if(if, then, else)<br />
if(conditions, A) A if conditions are True; temporal topological relation between if and then is equal.<br />
if(conditions, A, B) A if conditions are True, B otherwise; temporal topological relation between if, then and else is equal.<br />
if(topologies, conditions, A) A if conditions are True; temporal topological relation between if and then is explicit specified by topologies.<br />
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.<br />
</pre></div><br />
The conditions are comparison expressions that are used to evaluate <br />
space time datasets. Specific values of temporal variables are <br />
compared by logical operators and evaluated for each map of the STDS.<br />
<br><br />
<br><br />
The supported logical operators:<br />
<div class="code"><pre><br />
Symbol description<br />
<br />
== equal<br />
!= not equal<br />
> greater than<br />
>= greater than or equal<br />
< less than<br />
<= less than or equal<br />
&& and<br />
|| or<br />
</pre></div><br />
<br />
Temporal functions: <br><br />
<div class="code"><pre><br />
<br />
td(A) Returns a list of time intervals of STDS A<br />
<br />
start_time() Start time as HH::MM:SS<br />
start_date() Start date as yyyy-mm-DD<br />
start_datetime() Start datetime as yyyy-mm-DD HH:MM:SS<br />
end_time() End time as HH:MM:SS<br />
end_date() End date as yyyy-mm-DD<br />
end_datetime() End datetime as yyyy-mm-DD HH:MM<br />
<br />
start_doy() Day of year (doy) from the start time [1 - 366]<br />
start_dow() Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1<br />
start_year() The year of the start time [0 - 9999]<br />
start_month() The month of the start time [1 - 12]<br />
start_week() Week of year of the start time [1 - 54]<br />
start_day() Day of month from the start time [1 - 31]<br />
start_hour() The hour of the start time [0 - 23]<br />
start_minute() The minute of the start time [0 - 59]<br />
start_second() The second of the start time [0 - 59]<br />
end_doy() Day of year (doy) from the end time [1 - 366]<br />
end_dow() Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1<br />
end_year() The year of the end time [0 - 9999]<br />
end_month() The month of the end time [1 - 12]<br />
end_week() Week of year of the end time [1 - 54]<br />
end_day() Day of month from the start time [1 - 31]<br />
end_hour() The hour of the end time [0 - 23]<br />
end_minute() The minute of the end time [0 - 59]<br />
end_second() The second of the end time [0 - 59] <br />
</pre></div><br />
<br />
Additionally the number of maps in intervals can be computed and <br />
used in conditional statements. <br><br />
The operator to count the number of maps <br />
is the hash <b>#</b>. <br />
<div class="code"><pre><br />
A{contains,#}B<br />
</pre></div><br />
This expression computes the number of maps from space <br />
time dataset B which are during the time intervals of maps from <br />
space time dataset A.<br><br />
A list of integers (scalars) corresponding to the maps of A <br />
that contain maps from B will be returned. <br><br />
<br><br />
<br />
Furthermore the temporal algebra allows temporal buffering, shifting <br />
and snapping with the functions buff_t(), tshift() and tsnap()<br />
respectively.<br />
<div class="code"><pre><br />
buff_t(A, size) Buffer STDS A with granule ("1 month" or 5)<br />
tshift(A, size) Shift STDS A with granule ("1 month" or 5)<br />
tsnap(A) Snap time instances and intervals of STDS A<br />
</pre></div><br />
<br />
<h3>Examples</h3><br />
<br />
Select all maps from space time dataset A which have equal time stamps <br />
with space time dataset B and C and are ealier that Jan. 1. 2005 and <br />
store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(start_date() < "2005-01-01", A : B : C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset A which contains more than three<br />
maps of space time dataset B, else select maps from C with time<br />
stamps that are not equal to A and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(A {contain, #} B > 3, A {contain, :} B, C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset B which are during the temporal <br />
buffered space time dataset A with a map interval of three days, else<br />
select maps from C and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(contain, td(buff_t(A, "1 days")) == 3, B, C)<br />
</pre></div><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || {{done}}<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || {{done}}<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || {{done}}<br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || {{done}}<br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| in progress<br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
== Week 9 - 2012-07-26 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented functions for temporal operators into the temporal algebra.<br />
* Finsihed the module t.select.<br />
* Wrote the manual page for t.select.<br />
* Started to implement vector operations into the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue documentation of the GRASS module t.select and the integration of the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 10 - 2012-08-02 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Fixed bugs in the temporal algebra.<br />
* More testing of the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the integration of the vector operations into the temporal vector algebra and write documentation and tests.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 11 - 2012-08-09 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Finished implementation of vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Integrated a new function to evaluate spatio-temporal operators with PLY.<br />
* Worked on a lot minor fixes and tests.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Finish the the temporal vector algebra and write documentation. Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19645GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-08-12T15:24:27Z<p>Mastho: /* Weekly Reports */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= t.select =<br />
<br />
== Description ==<br />
t.select performs selection of maps that are registered in space time datasets using temporal algebra.<br />
<br />
== Program Use ==<br />
The module expects an <b>expression</b> as input parameter in the following form: <br><br />
<br><br />
<b> "result = expression" </b><br />
<br><br />
<br><br />
<br />
The statement structure is similar to r.mapcalc.<br />
Where <b>result</b> represents the name of a space time dataset (STDS)that will <br />
contain the result of the calculation that is given as <b>expression</b> <br />
on the right side of the equality sign. <br />
These expression can be any valid or nested combination of temporal <br />
operations and functions that are provided by the temporal algebra. <br><br />
The temporal algebra works with space time datasets of any type (STRDS, STR3DS and STVDS). <br />
The algebra provides methods for map selection from STDS based on their temporal relations. <br />
It is also possible to temporally shift maps, to create temporal buffer and to snap time <br />
instances to create a valid temporal topology. Furthermore expressions can be nested and <br />
evaluated in conditional statements (if, else statements). Within if-statements the algebra <br />
provides temporal variables like start time, end time, day of year, time differences or <br />
number of maps per time interval to build up conditions. These operations can be assigned <br />
to space time datasets or to the results of operations between space time datasets. <br />
<br><br />
<br><br />
The type of the input space time datasets must be defined with the input <br />
parameter <b>type</b>. Possible options are STRDS, STVDS or STR3DS. <br />
The default is set to space time raster datasets (STRDS).<br />
<br><br />
<br><br />
As default, topological relationships between space time datasets will be <br />
evaluated only temporal. Use the <b>s</b> flag to activate the <br />
additionally spatial topology evaluation.<br />
<br><br />
<br><br />
The expression option must be passed as <b>quoted</b> <br />
expression, for example: <br><br />
<div class="code"><pre>t.select expression="C = A : B"</pre></div> <br />
Where <b>C</b> is the new space time raster dataset that will contain maps<br />
from <b>A</b> that are selected by equal temporal relationships <br />
to the existing dataset <b>B</b> in this case. <br><br />
<br><br />
<br />
== Temporal Algebra for t.select==<br />
The temporal algebra provides a wide range of temporal operators and <br />
functions that will be presented in the following section. <br><br />
<br><br />
<br />
<h3>Temporal relations</h3><br />
<br />
Several temporal topology relations between space <br />
time datasets are supported: <br><br />
<div class="code"><pre><br />
equals A ------<br />
B ------<br />
<br />
during A ---- <br />
B ------<br />
<br />
contains A ------<br />
B ---- <br />
<br />
starts A ----<br />
B ------<br />
<br />
started A ------<br />
B ----<br />
<br />
finishs A ---- <br />
B ------<br />
<br />
finished A ------<br />
B ----<br />
<br />
precedes A ----<br />
B ----<br />
<br />
follows A ----<br />
B ----<br />
<br />
overlapped A ------<br />
B ------<br />
<br />
overlaps A ------<br />
B ------<br />
<br />
over booth overlaps and overlapped<br />
<br />
</pre></div><br />
The relations must be read as: A is related to B, like - A equals B - A is <br />
during B - A contains B <br><br />
<br><br />
Topological relations must be specified in {} parentheses. <br><br />
<br />
<h3>Temporal selection</h3><br />
<br />
The temporal selection simply selects parts of a space time dataset without <br />
processing raster or vector data.<br />
<br />
The algebra provides a selection operator <b>:</b> that selects parts <br />
of a space time dataset that are temporally equal to parts of a second one <br />
by default. The following expression<br />
<div class="code"><pre><br />
C = A : B<br />
</pre></div><br />
means: Select all parts of space time dataset A that are equal to B and store <br />
it in space time dataset C. The parts are in this case time stamped maps. <br><br />
<br><br />
In addition the inverse selection operator <b>!:</b> is defined as the complement of <br />
the selection operator, hence the following expression<br />
<div class="code"><pre><br />
C = A !: B<br />
</pre></div><br />
means: select all parts of space time time dataset A that are not equal to B <br />
and store it in space time dataset (STDS) C. <br><br />
<br><br />
To select parts of a STDS by different topological relations to other STDS, <br />
the temporal topology selection operator can be used. The operator consists of <br />
topological relations, that must be separated by the logical OR operator <br />
<b>||</b> and the temporal selection operator. Both parts are separated by <br />
comma and surrounded by curly braces: <br />
{"topological relations", "temporal selection operator"} <br><br />
<br><br />
Examples:<br />
<div class="code"><pre><br />
C = A {equals,:} B<br />
C = A {equals,!:} B<br />
</pre></div><br />
We can now define arbitrary topological relations using logical OR operator <br />
to connect them:<br />
<div class="code"><pre><br />
C = A {equals||during||overlaps,:} B<br />
</pre></div><br />
Select all parts of A that are equal to B, during B or overlaps B. <br><br />
<br><br />
The selection operator is implicitly contained in the temporal topology <br />
selection operator, so that the following statements are exactly the same:<br />
<div class="code"><pre><br />
C = A : B<br />
C = A {:} B<br />
C = A {equal,:} B<br />
</pre></div><br />
<br />
Same for the complementary selection:<br />
<div class="code"><pre><br />
C = A !: B<br />
C = A {!:} B<br />
C = A {equal,!:} B<br />
</pre></div><br />
<br />
<h3>Conditional statements</h3><br />
<br />
Selection operations can be evaluated within conditional statements.<br />
<br><br />
<div class="code"><pre><br />
Note A and B can either be space time datasets or expressions.<br />
<br />
if statement decision option temporal relations<br />
if(if, then, else)<br />
if(conditions, A) A if conditions are True; temporal topological relation between if and then is equal.<br />
if(conditions, A, B) A if conditions are True, B otherwise; temporal topological relation between if, then and else is equal.<br />
if(topologies, conditions, A) A if conditions are True; temporal topological relation between if and then is explicit specified by topologies.<br />
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.<br />
</pre></div><br />
The conditions are comparison expressions that are used to evaluate <br />
space time datasets. Specific values of temporal variables are <br />
compared by logical operators and evaluated for each map of the STDS.<br />
<br><br />
<br><br />
The supported logical operators:<br />
<div class="code"><pre><br />
Symbol description<br />
<br />
== equal<br />
!= not equal<br />
> greater than<br />
>= greater than or equal<br />
< less than<br />
<= less than or equal<br />
&& and<br />
|| or<br />
</pre></div><br />
<br />
Temporal functions: <br><br />
<div class="code"><pre><br />
<br />
td(A) Returns a list of time intervals of STDS A<br />
<br />
start_time() Start time as HH::MM:SS<br />
start_date() Start date as yyyy-mm-DD<br />
start_datetime() Start datetime as yyyy-mm-DD HH:MM:SS<br />
end_time() End time as HH:MM:SS<br />
end_date() End date as yyyy-mm-DD<br />
end_datetime() End datetime as yyyy-mm-DD HH:MM<br />
<br />
start_doy() Day of year (doy) from the start time [1 - 366]<br />
start_dow() Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1<br />
start_year() The year of the start time [0 - 9999]<br />
start_month() The month of the start time [1 - 12]<br />
start_week() Week of year of the start time [1 - 54]<br />
start_day() Day of month from the start time [1 - 31]<br />
start_hour() The hour of the start time [0 - 23]<br />
start_minute() The minute of the start time [0 - 59]<br />
start_second() The second of the start time [0 - 59]<br />
end_doy() Day of year (doy) from the end time [1 - 366]<br />
end_dow() Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1<br />
end_year() The year of the end time [0 - 9999]<br />
end_month() The month of the end time [1 - 12]<br />
end_week() Week of year of the end time [1 - 54]<br />
end_day() Day of month from the start time [1 - 31]<br />
end_hour() The hour of the end time [0 - 23]<br />
end_minute() The minute of the end time [0 - 59]<br />
end_second() The second of the end time [0 - 59] <br />
</pre></div><br />
<br />
Additionally the number of maps in intervals can be computed and <br />
used in conditional statements. <br><br />
The operator to count the number of maps <br />
is the hash <b>#</b>. <br />
<div class="code"><pre><br />
A{contains,#}B<br />
</pre></div><br />
This expression computes the number of maps from space <br />
time dataset B which are during the time intervals of maps from <br />
space time dataset A.<br><br />
A list of integers (scalars) corresponding to the maps of A <br />
that contain maps from B will be returned. <br><br />
<br><br />
<br />
Furthermore the temporal algebra allows temporal buffering, shifting <br />
and snapping with the functions buff_t(), tshift() and tsnap()<br />
respectively.<br />
<div class="code"><pre><br />
buff_t(A, size) Buffer STDS A with granule ("1 month" or 5)<br />
tshift(A, size) Shift STDS A with granule ("1 month" or 5)<br />
tsnap(A) Snap time instances and intervals of STDS A<br />
</pre></div><br />
<br />
<h3>Examples</h3><br />
<br />
Select all maps from space time dataset A which have equal time stamps <br />
with space time dataset B and C and are ealier that Jan. 1. 2005 and <br />
store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(start_date() < "2005-01-01", A : B : C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset A which contains more than three<br />
maps of space time dataset B, else select maps from C with time<br />
stamps that are not equal to A and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(A {contain, #} B > 3, A {contain, :} B, C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset B which are during the temporal <br />
buffered space time dataset A with a map interval of three days, else<br />
select maps from C and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(contain, td(buff_t(A, "1 days")) == 3, B, C)<br />
</pre></div><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || {{done}}<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || {{done}}<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || in progress<br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
== Week 9 - 2012-07-26 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented functions for temporal operators into the temporal algebra.<br />
* Finsihed the module t.select.<br />
* Wrote the manual page for t.select.<br />
* Started to implement vector operations into the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue documentation of the GRASS module t.select and the integration of the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 10 - 2012-08-02 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Fixed bugs in the temporal algebra.<br />
* More testing of the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the integration of the vector operations into the temporal vector algebra and write documentation and tests.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 11 - 2012-08-09 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Finished implementation of vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Integrated a new function to evaluate spatio-temporal operators with PLY.<br />
* Worked on a lot minor fixes and tests.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Finish the the temporal vector algebra and write documentation. Start implementing the temporal raster algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19546GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-08-02T16:16:41Z<p>Mastho: /* Weekly Reports */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= t.select =<br />
<br />
== Description ==<br />
t.select performs selection of maps that are registered in space time datasets using temporal algebra.<br />
<br />
== Program Use ==<br />
The module expects an <b>expression</b> as input parameter in the following form: <br><br />
<br><br />
<b> "result = expression" </b><br />
<br><br />
<br><br />
<br />
The statement structure is similar to r.mapcalc.<br />
Where <b>result</b> represents the name of a space time dataset (STDS)that will <br />
contain the result of the calculation that is given as <b>expression</b> <br />
on the right side of the equality sign. <br />
These expression can be any valid or nested combination of temporal <br />
operations and functions that are provided by the temporal algebra. <br><br />
The temporal algebra works with space time datasets of any type (STRDS, STR3DS and STVDS). <br />
The algebra provides methods for map selection from STDS based on their temporal relations. <br />
It is also possible to temporally shift maps, to create temporal buffer and to snap time <br />
instances to create a valid temporal topology. Furthermore expressions can be nested and <br />
evaluated in conditional statements (if, else statements). Within if-statements the algebra <br />
provides temporal variables like start time, end time, day of year, time differences or <br />
number of maps per time interval to build up conditions. These operations can be assigned <br />
to space time datasets or to the results of operations between space time datasets. <br />
<br><br />
<br><br />
The type of the input space time datasets must be defined with the input <br />
parameter <b>type</b>. Possible options are STRDS, STVDS or STR3DS. <br />
The default is set to space time raster datasets (STRDS).<br />
<br><br />
<br><br />
As default, topological relationships between space time datasets will be <br />
evaluated only temporal. Use the <b>s</b> flag to activate the <br />
additionally spatial topology evaluation.<br />
<br><br />
<br><br />
The expression option must be passed as <b>quoted</b> <br />
expression, for example: <br><br />
<div class="code"><pre>t.select expression="C = A : B"</pre></div> <br />
Where <b>C</b> is the new space time raster dataset that will contain maps<br />
from <b>A</b> that are selected by equal temporal relationships <br />
to the existing dataset <b>B</b> in this case. <br><br />
<br><br />
<br />
== Temporal Algebra for t.select==<br />
The temporal algebra provides a wide range of temporal operators and <br />
functions that will be presented in the following section. <br><br />
<br><br />
<br />
<h3>Temporal relations</h3><br />
<br />
Several temporal topology relations between space <br />
time datasets are supported: <br><br />
<div class="code"><pre><br />
equals A ------<br />
B ------<br />
<br />
during A ---- <br />
B ------<br />
<br />
contains A ------<br />
B ---- <br />
<br />
starts A ----<br />
B ------<br />
<br />
started A ------<br />
B ----<br />
<br />
finishs A ---- <br />
B ------<br />
<br />
finished A ------<br />
B ----<br />
<br />
precedes A ----<br />
B ----<br />
<br />
follows A ----<br />
B ----<br />
<br />
overlapped A ------<br />
B ------<br />
<br />
overlaps A ------<br />
B ------<br />
<br />
over booth overlaps and overlapped<br />
<br />
</pre></div><br />
The relations must be read as: A is related to B, like - A equals B - A is <br />
during B - A contains B <br><br />
<br><br />
Topological relations must be specified in {} parentheses. <br><br />
<br />
<h3>Temporal selection</h3><br />
<br />
The temporal selection simply selects parts of a space time dataset without <br />
processing raster or vector data.<br />
<br />
The algebra provides a selection operator <b>:</b> that selects parts <br />
of a space time dataset that are temporally equal to parts of a second one <br />
by default. The following expression<br />
<div class="code"><pre><br />
C = A : B<br />
</pre></div><br />
means: Select all parts of space time dataset A that are equal to B and store <br />
it in space time dataset C. The parts are in this case time stamped maps. <br><br />
<br><br />
In addition the inverse selection operator <b>!:</b> is defined as the complement of <br />
the selection operator, hence the following expression<br />
<div class="code"><pre><br />
C = A !: B<br />
</pre></div><br />
means: select all parts of space time time dataset A that are not equal to B <br />
and store it in space time dataset (STDS) C. <br><br />
<br><br />
To select parts of a STDS by different topological relations to other STDS, <br />
the temporal topology selection operator can be used. The operator consists of <br />
topological relations, that must be separated by the logical OR operator <br />
<b>||</b> and the temporal selection operator. Both parts are separated by <br />
comma and surrounded by curly braces: <br />
{"topological relations", "temporal selection operator"} <br><br />
<br><br />
Examples:<br />
<div class="code"><pre><br />
C = A {equals,:} B<br />
C = A {equals,!:} B<br />
</pre></div><br />
We can now define arbitrary topological relations using logical OR operator <br />
to connect them:<br />
<div class="code"><pre><br />
C = A {equals||during||overlaps,:} B<br />
</pre></div><br />
Select all parts of A that are equal to B, during B or overlaps B. <br><br />
<br><br />
The selection operator is implicitly contained in the temporal topology <br />
selection operator, so that the following statements are exactly the same:<br />
<div class="code"><pre><br />
C = A : B<br />
C = A {:} B<br />
C = A {equal,:} B<br />
</pre></div><br />
<br />
Same for the complementary selection:<br />
<div class="code"><pre><br />
C = A !: B<br />
C = A {!:} B<br />
C = A {equal,!:} B<br />
</pre></div><br />
<br />
<h3>Conditional statements</h3><br />
<br />
Selection operations can be evaluated within conditional statements.<br />
<br><br />
<div class="code"><pre><br />
Note A and B can either be space time datasets or expressions.<br />
<br />
if statement decision option temporal relations<br />
if(if, then, else)<br />
if(conditions, A) A if conditions are True; temporal topological relation between if and then is equal.<br />
if(conditions, A, B) A if conditions are True, B otherwise; temporal topological relation between if, then and else is equal.<br />
if(topologies, conditions, A) A if conditions are True; temporal topological relation between if and then is explicit specified by topologies.<br />
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.<br />
</pre></div><br />
The conditions are comparison expressions that are used to evaluate <br />
space time datasets. Specific values of temporal variables are <br />
compared by logical operators and evaluated for each map of the STDS.<br />
<br><br />
<br><br />
The supported logical operators:<br />
<div class="code"><pre><br />
Symbol description<br />
<br />
== equal<br />
!= not equal<br />
> greater than<br />
>= greater than or equal<br />
< less than<br />
<= less than or equal<br />
&& and<br />
|| or<br />
</pre></div><br />
<br />
Temporal functions: <br><br />
<div class="code"><pre><br />
<br />
td(A) Returns a list of time intervals of STDS A<br />
<br />
start_time() Start time as HH::MM:SS<br />
start_date() Start date as yyyy-mm-DD<br />
start_datetime() Start datetime as yyyy-mm-DD HH:MM:SS<br />
end_time() End time as HH:MM:SS<br />
end_date() End date as yyyy-mm-DD<br />
end_datetime() End datetime as yyyy-mm-DD HH:MM<br />
<br />
start_doy() Day of year (doy) from the start time [1 - 366]<br />
start_dow() Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1<br />
start_year() The year of the start time [0 - 9999]<br />
start_month() The month of the start time [1 - 12]<br />
start_week() Week of year of the start time [1 - 54]<br />
start_day() Day of month from the start time [1 - 31]<br />
start_hour() The hour of the start time [0 - 23]<br />
start_minute() The minute of the start time [0 - 59]<br />
start_second() The second of the start time [0 - 59]<br />
end_doy() Day of year (doy) from the end time [1 - 366]<br />
end_dow() Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1<br />
end_year() The year of the end time [0 - 9999]<br />
end_month() The month of the end time [1 - 12]<br />
end_week() Week of year of the end time [1 - 54]<br />
end_day() Day of month from the start time [1 - 31]<br />
end_hour() The hour of the end time [0 - 23]<br />
end_minute() The minute of the end time [0 - 59]<br />
end_second() The second of the end time [0 - 59] <br />
</pre></div><br />
<br />
Additionally the number of maps in intervals can be computed and <br />
used in conditional statements. <br><br />
The operator to count the number of maps <br />
is the hash <b>#</b>. <br />
<div class="code"><pre><br />
A{contains,#}B<br />
</pre></div><br />
This expression computes the number of maps from space <br />
time dataset B which are during the time intervals of maps from <br />
space time dataset A.<br><br />
A list of integers (scalars) corresponding to the maps of A <br />
that contain maps from B will be returned. <br><br />
<br><br />
<br />
Furthermore the temporal algebra allows temporal buffering, shifting <br />
and snapping with the functions buff_t(), tshift() and tsnap()<br />
respectively.<br />
<div class="code"><pre><br />
buff_t(A, size) Buffer STDS A with granule ("1 month" or 5)<br />
tshift(A, size) Shift STDS A with granule ("1 month" or 5)<br />
tsnap(A) Snap time instances and intervals of STDS A<br />
</pre></div><br />
<br />
<h3>Examples</h3><br />
<br />
Select all maps from space time dataset A which have equal time stamps <br />
with space time dataset B and C and are ealier that Jan. 1. 2005 and <br />
store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(start_date() < "2005-01-01", A : B : C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset A which contains more than three<br />
maps of space time dataset B, else select maps from C with time<br />
stamps that are not equal to A and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(A {contain, #} B > 3, A {contain, :} B, C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset B which are during the temporal <br />
buffered space time dataset A with a map interval of three days, else<br />
select maps from C and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(contain, td(buff_t(A, "1 days")) == 3, B, C)<br />
</pre></div><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || {{done}}<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || {{done}}<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || in progress<br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
== Week 9 - 2012-07-26 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented functions for temporal operators into the temporal algebra.<br />
* Finsihed the module t.select.<br />
* Wrote the manual page for t.select.<br />
* Started to implement vector operations into the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue documentation of the GRASS module t.select and the integration of the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
== Week 10 - 2012-08-02 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented vector operations for the vector overlay function like (intersection, union, disjoint union, exclusive union and the complement).<br />
* Fixed bugs in the temporal algebra.<br />
* More testing of the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the integration of the vector operations into the temporal vector algebra and write documentation and tests.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19393GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-07-26T16:13:35Z<p>Mastho: /* Temporal Algebra for t.select */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= t.select =<br />
<br />
== Description ==<br />
t.select performs selection of maps that are registered in space time datasets using temporal algebra.<br />
<br />
== Program Use ==<br />
The module expects an <b>expression</b> as input parameter in the following form: <br><br />
<br><br />
<b> "result = expression" </b><br />
<br><br />
<br><br />
<br />
The statement structure is similar to r.mapcalc.<br />
Where <b>result</b> represents the name of a space time dataset (STDS)that will <br />
contain the result of the calculation that is given as <b>expression</b> <br />
on the right side of the equality sign. <br />
These expression can be any valid or nested combination of temporal <br />
operations and functions that are provided by the temporal algebra. <br><br />
The temporal algebra works with space time datasets of any type (STRDS, STR3DS and STVDS). <br />
The algebra provides methods for map selection from STDS based on their temporal relations. <br />
It is also possible to temporally shift maps, to create temporal buffer and to snap time <br />
instances to create a valid temporal topology. Furthermore expressions can be nested and <br />
evaluated in conditional statements (if, else statements). Within if-statements the algebra <br />
provides temporal variables like start time, end time, day of year, time differences or <br />
number of maps per time interval to build up conditions. These operations can be assigned <br />
to space time datasets or to the results of operations between space time datasets. <br />
<br><br />
<br><br />
The type of the input space time datasets must be defined with the input <br />
parameter <b>type</b>. Possible options are STRDS, STVDS or STR3DS. <br />
The default is set to space time raster datasets (STRDS).<br />
<br><br />
<br><br />
As default, topological relationships between space time datasets will be <br />
evaluated only temporal. Use the <b>s</b> flag to activate the <br />
additionally spatial topology evaluation.<br />
<br><br />
<br><br />
The expression option must be passed as <b>quoted</b> <br />
expression, for example: <br><br />
<div class="code"><pre>t.select expression="C = A : B"</pre></div> <br />
Where <b>C</b> is the new space time raster dataset that will contain maps<br />
from <b>A</b> that are selected by equal temporal relationships <br />
to the existing dataset <b>B</b> in this case. <br><br />
<br><br />
<br />
== Temporal Algebra for t.select==<br />
The temporal algebra provides a wide range of temporal operators and <br />
functions that will be presented in the following section. <br><br />
<br><br />
<br />
<h3>Temporal relations</h3><br />
<br />
Several temporal topology relations between space <br />
time datasets are supported: <br><br />
<div class="code"><pre><br />
equals A ------<br />
B ------<br />
<br />
during A ---- <br />
B ------<br />
<br />
contains A ------<br />
B ---- <br />
<br />
starts A ----<br />
B ------<br />
<br />
started A ------<br />
B ----<br />
<br />
finishs A ---- <br />
B ------<br />
<br />
finished A ------<br />
B ----<br />
<br />
precedes A ----<br />
B ----<br />
<br />
follows A ----<br />
B ----<br />
<br />
overlapped A ------<br />
B ------<br />
<br />
overlaps A ------<br />
B ------<br />
<br />
over booth overlaps and overlapped<br />
<br />
</pre></div><br />
The relations must be read as: A is related to B, like - A equals B - A is <br />
during B - A contains B <br><br />
<br><br />
Topological relations must be specified in {} parentheses. <br><br />
<br />
<h3>Temporal selection</h3><br />
<br />
The temporal selection simply selects parts of a space time dataset without <br />
processing raster or vector data.<br />
<br />
The algebra provides a selection operator <b>:</b> that selects parts <br />
of a space time dataset that are temporally equal to parts of a second one <br />
by default. The following expression<br />
<div class="code"><pre><br />
C = A : B<br />
</pre></div><br />
means: Select all parts of space time dataset A that are equal to B and store <br />
it in space time dataset C. The parts are in this case time stamped maps. <br><br />
<br><br />
In addition the inverse selection operator <b>!:</b> is defined as the complement of <br />
the selection operator, hence the following expression<br />
<div class="code"><pre><br />
C = A !: B<br />
</pre></div><br />
means: select all parts of space time time dataset A that are not equal to B <br />
and store it in space time dataset (STDS) C. <br><br />
<br><br />
To select parts of a STDS by different topological relations to other STDS, <br />
the temporal topology selection operator can be used. The operator consists of <br />
topological relations, that must be separated by the logical OR operator <br />
<b>||</b> and the temporal selection operator. Both parts are separated by <br />
comma and surrounded by curly braces: <br />
{"topological relations", "temporal selection operator"} <br><br />
<br><br />
Examples:<br />
<div class="code"><pre><br />
C = A {equals,:} B<br />
C = A {equals,!:} B<br />
</pre></div><br />
We can now define arbitrary topological relations using logical OR operator <br />
to connect them:<br />
<div class="code"><pre><br />
C = A {equals||during||overlaps,:} B<br />
</pre></div><br />
Select all parts of A that are equal to B, during B or overlaps B. <br><br />
<br><br />
The selection operator is implicitly contained in the temporal topology <br />
selection operator, so that the following statements are exactly the same:<br />
<div class="code"><pre><br />
C = A : B<br />
C = A {:} B<br />
C = A {equal,:} B<br />
</pre></div><br />
<br />
Same for the complementary selection:<br />
<div class="code"><pre><br />
C = A !: B<br />
C = A {!:} B<br />
C = A {equal,!:} B<br />
</pre></div><br />
<br />
<h3>Conditional statements</h3><br />
<br />
Selection operations can be evaluated within conditional statements.<br />
<br><br />
<div class="code"><pre><br />
Note A and B can either be space time datasets or expressions.<br />
<br />
if statement decision option temporal relations<br />
if(if, then, else)<br />
if(conditions, A) A if conditions are True; temporal topological relation between if and then is equal.<br />
if(conditions, A, B) A if conditions are True, B otherwise; temporal topological relation between if, then and else is equal.<br />
if(topologies, conditions, A) A if conditions are True; temporal topological relation between if and then is explicit specified by topologies.<br />
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.<br />
</pre></div><br />
The conditions are comparison expressions that are used to evaluate <br />
space time datasets. Specific values of temporal variables are <br />
compared by logical operators and evaluated for each map of the STDS.<br />
<br><br />
<br><br />
The supported logical operators:<br />
<div class="code"><pre><br />
Symbol description<br />
<br />
== equal<br />
!= not equal<br />
> greater than<br />
>= greater than or equal<br />
< less than<br />
<= less than or equal<br />
&& and<br />
|| or<br />
</pre></div><br />
<br />
Temporal functions: <br><br />
<div class="code"><pre><br />
<br />
td(A) Returns a list of time intervals of STDS A<br />
<br />
start_time() Start time as HH::MM:SS<br />
start_date() Start date as yyyy-mm-DD<br />
start_datetime() Start datetime as yyyy-mm-DD HH:MM:SS<br />
end_time() End time as HH:MM:SS<br />
end_date() End date as yyyy-mm-DD<br />
end_datetime() End datetime as yyyy-mm-DD HH:MM<br />
<br />
start_doy() Day of year (doy) from the start time [1 - 366]<br />
start_dow() Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1<br />
start_year() The year of the start time [0 - 9999]<br />
start_month() The month of the start time [1 - 12]<br />
start_week() Week of year of the start time [1 - 54]<br />
start_day() Day of month from the start time [1 - 31]<br />
start_hour() The hour of the start time [0 - 23]<br />
start_minute() The minute of the start time [0 - 59]<br />
start_second() The second of the start time [0 - 59]<br />
end_doy() Day of year (doy) from the end time [1 - 366]<br />
end_dow() Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1<br />
end_year() The year of the end time [0 - 9999]<br />
end_month() The month of the end time [1 - 12]<br />
end_week() Week of year of the end time [1 - 54]<br />
end_day() Day of month from the start time [1 - 31]<br />
end_hour() The hour of the end time [0 - 23]<br />
end_minute() The minute of the end time [0 - 59]<br />
end_second() The second of the end time [0 - 59] <br />
</pre></div><br />
<br />
Additionally the number of maps in intervals can be computed and <br />
used in conditional statements. <br><br />
The operator to count the number of maps <br />
is the hash <b>#</b>. <br />
<div class="code"><pre><br />
A{contains,#}B<br />
</pre></div><br />
This expression computes the number of maps from space <br />
time dataset B which are during the time intervals of maps from <br />
space time dataset A.<br><br />
A list of integers (scalars) corresponding to the maps of A <br />
that contain maps from B will be returned. <br><br />
<br><br />
<br />
Furthermore the temporal algebra allows temporal buffering, shifting <br />
and snapping with the functions buff_t(), tshift() and tsnap()<br />
respectively.<br />
<div class="code"><pre><br />
buff_t(A, size) Buffer STDS A with granule ("1 month" or 5)<br />
tshift(A, size) Shift STDS A with granule ("1 month" or 5)<br />
tsnap(A) Snap time instances and intervals of STDS A<br />
</pre></div><br />
<br />
<h3>Examples</h3><br />
<br />
Select all maps from space time dataset A which have equal time stamps <br />
with space time dataset B and C and are ealier that Jan. 1. 2005 and <br />
store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(start_date() < "2005-01-01", A : B : C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset A which contains more than three<br />
maps of space time dataset B, else select maps from C with time<br />
stamps that are not equal to A and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(A {contain, #} B > 3, A {contain, :} B, C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset B which are during the temporal <br />
buffered space time dataset A with a map interval of three days, else<br />
select maps from C and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(contain, td(buff_t(A, "1 days")) == 3, B, C)<br />
</pre></div><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || {{done}}<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || {{done}}<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || in progress<br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
== Week 9 - 2012-07-26 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented functions for temporal operators into the temporal algebra.<br />
* Finsihed the module t.select.<br />
* Wrote the manual page for t.select.<br />
* Started to implement vector operations into the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue documentation of the GRASS module t.select and the integration of the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19392GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-07-26T16:12:13Z<p>Mastho: </p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= t.select =<br />
<br />
== Description ==<br />
t.select performs selection of maps that are registered in space time datasets using temporal algebra.<br />
<br />
== Program Use ==<br />
The module expects an <b>expression</b> as input parameter in the following form: <br><br />
<br><br />
<b> "result = expression" </b><br />
<br><br />
<br><br />
<br />
The statement structure is similar to r.mapcalc.<br />
Where <b>result</b> represents the name of a space time dataset (STDS)that will <br />
contain the result of the calculation that is given as <b>expression</b> <br />
on the right side of the equality sign. <br />
These expression can be any valid or nested combination of temporal <br />
operations and functions that are provided by the temporal algebra. <br><br />
The temporal algebra works with space time datasets of any type (STRDS, STR3DS and STVDS). <br />
The algebra provides methods for map selection from STDS based on their temporal relations. <br />
It is also possible to temporally shift maps, to create temporal buffer and to snap time <br />
instances to create a valid temporal topology. Furthermore expressions can be nested and <br />
evaluated in conditional statements (if, else statements). Within if-statements the algebra <br />
provides temporal variables like start time, end time, day of year, time differences or <br />
number of maps per time interval to build up conditions. These operations can be assigned <br />
to space time datasets or to the results of operations between space time datasets. <br />
<br><br />
<br><br />
The type of the input space time datasets must be defined with the input <br />
parameter <b>type</b>. Possible options are STRDS, STVDS or STR3DS. <br />
The default is set to space time raster datasets (STRDS).<br />
<br><br />
<br><br />
As default, topological relationships between space time datasets will be <br />
evaluated only temporal. Use the <b>s</b> flag to activate the <br />
additionally spatial topology evaluation.<br />
<br><br />
<br><br />
The expression option must be passed as <b>quoted</b> <br />
expression, for example: <br><br />
<div class="code"><pre>t.select expression="C = A : B"</pre></div> <br />
Where <b>C</b> is the new space time raster dataset that will contain maps<br />
from <b>A</b> that are selected by equal temporal relationships <br />
to the existing dataset <b>B</b> in this case. <br><br />
<br><br />
<br />
== Temporal Algebra for t.select==<br />
The temporal algebra provides a wide range of temporal operators and <br />
functions that will be presented in the following section. <br><br />
<br><br />
<br />
<h3>Temporal relations</h3><br />
<br />
Several temporal topology relations between space <br />
time datasets are supported: <br><br />
<div class="code"><pre><br />
equals A ------<br />
B ------<br />
<br />
during A ---- <br />
B ------<br />
<br />
contains A ------<br />
B ---- <br />
<br />
starts A ----<br />
B ------<br />
<br />
started A ------<br />
B ----<br />
<br />
finishs A ---- <br />
B ------<br />
<br />
finished A ------<br />
B ----<br />
<br />
precedes A ----<br />
B ----<br />
<br />
follows A ----<br />
B ----<br />
<br />
overlapped A ------<br />
B ------<br />
<br />
overlaps A ------<br />
B ------<br />
<br />
over booth overlaps and overlapped<br />
<br />
</pre></div><br />
The relations must be read as: A is related to B, like - A equals B - A is <br />
during B - A contains B <br><br />
<br><br />
Topological relations must be specified in {} parentheses. <br><br />
<br />
<h3>Temporal selection</h3><br />
<br />
The temporal selection simply selects parts of a space time dataset without <br />
processing raster or vector data.<br />
<br />
The algebra provides a selection operator <b>:</b> that selects parts <br />
of a space time dataset that are temporally equal to parts of a second one <br />
by default. The following expression<br />
<div class="code"><pre><br />
C = A : B<br />
</pre></div><br />
means: Select all parts of space time dataset A that are equal to B and store <br />
it in space time dataset C. The parts are in this case time stamped maps. <br><br />
<br><br />
In addition the inverse selection operator <b>!:</b> is defined as the complement of <br />
the selection operator, hence the following expression<br />
<div class="code"><pre><br />
C = A !: B<br />
</pre></div><br />
means: select all parts of space time time dataset A that are not equal to B <br />
and store it in space time dataset (STDS) C. <br><br />
<br><br />
To select parts of a STDS by different topological relations to other STDS, <br />
the temporal topology selection operator can be used. The operator consists of <br />
topological relations, that must be separated by the logical OR operator <br />
<b>||</b> and the temporal selection operator. Both parts are separated by <br />
comma and surrounded by curly braces: <br />
{"topological relations", "temporal selection operator"} <br><br />
<br><br />
Examples:<br />
<div class="code"><pre><br />
C = A {equals,:} B<br />
C = A {equals,!:} B<br />
</pre></div><br />
We can now define arbitrary topological relations using logical OR operator <br />
to connect them:<br />
<div class="code"><pre><br />
C = A {equals||during||overlaps,:} B<br />
</pre></div><br />
Select all parts of A that are equal to B, during B or overlaps B. <br><br />
<br><br />
The selection operator is implicitly contained in the temporal topology <br />
selection operator, so that the following statements are exactly the same:<br />
<div class="code"><pre><br />
C = A : B<br />
C = A {:} B<br />
C = A {equal,:} B<br />
</pre></div><br />
<br />
Same for the complementary selection:<br />
<div class="code"><pre><br />
C = A !: B<br />
C = A {!:} B<br />
C = A {equal,!:} B<br />
</pre></div><br />
<br />
<h3>Conditional statements</h3><br />
<br />
Selection operations can be evaluated within conditional statements.<br />
<br><br />
<div class="code"><pre><br />
Note A and B can either be space time datasets or expressions.<br />
<br />
if statement decision option temporal relations<br />
if(if, then, else)<br />
if(conditions, A) A if conditions are True; temporal topological relation between if and then is equal.<br />
if(conditions, A, B) A if conditions are True, B otherwise; temporal topological relation between if, then and else is equal.<br />
if(topologies, conditions, A) A if conditions are True; temporal topological relation between if and then is explicit specified by topologies.<br />
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.<br />
</pre></div><br />
The conditions are comparison expressions that are used to evaluate <br />
space time datasets. Specific values of temporal variables are <br />
compared by logical operators and evaluated for each map of the STDS.<br />
<br><br />
<br><br />
The supported logical operators:<br />
<div class="code"><pre><br />
Symbol description<br />
<br />
== equal<br />
!= not equal<br />
> greater than<br />
>= greater than or equal<br />
< less than<br />
<= less than or equal<br />
&& and<br />
|| or<br />
</pre></div><br />
<br />
Temporal functions: <br><br />
<div class="code"><pre><br />
<br />
td(A) Returns a list of time intervals of STDS A<br />
<br />
start_time() Start time as HH::MM:SS<br />
start_date() Start date as yyyy-mm-DD<br />
start_datetime() Start datetime as yyyy-mm-DD HH:MM:SS<br />
end_time() End time as HH:MM:SS<br />
end_date() End date as yyyy-mm-DD<br />
end_datetime() End datetime as yyyy-mm-DD HH:MM<br />
<br />
start_doy() Day of year (doy) from the start time [1 - 366]<br />
start_dow() Day of week (dow) from the start time [1 - 7], the start of the week is Monday == 1<br />
start_year() The year of the start time [0 - 9999]<br />
start_month() The month of the start time [1 - 12]<br />
start_week() Week of year of the start time [1 - 54]<br />
start_day() Day of month from the start time [1 - 31]<br />
start_hour() The hour of the start time [0 - 23]<br />
start_minute() The minute of the start time [0 - 59]<br />
start_second() The second of the start time [0 - 59]<br />
end_doy() Day of year (doy) from the end time [1 - 366]<br />
end_dow() Day of week (dow) from the end time [1 - 7], the start of the week is Monday == 1<br />
end_year() The year of the end time [0 - 9999]<br />
end_month() The month of the end time [1 - 12]<br />
end_week() Week of year of the end time [1 - 54]<br />
end_day() Day of month from the start time [1 - 31]<br />
end_hour() The hour of the end time [0 - 23]<br />
end_minute() The minute of the end time [0 - 59]<br />
end_second() The second of the end time [0 - 59] <br />
</pre></div><br />
<br />
Additionally the number of maps in intervals can be computed and <br />
used in conditional statements. <br><br />
The operator to count the number of maps <br />
is the hash <b>#</b>. <br />
<div class="code"><pre><br />
A{contains,#}B<br />
</pre></div><br />
This expression computes the number of maps from space <br />
time dataset B which are during the time intervals of maps from <br />
space time dataset A.<br><br />
A list of integers (scalars) corresponding to the maps of A <br />
that contain maps from B will be returned. <br><br />
<br><br />
<br />
Furthermore the temporal algebra allows temporal buffering, shifting <br />
and snapping with the functions buff_t(), tshift() and tsnap()<br />
respectively.<br />
<div class="code"><pre><br />
buff_t(A, size) Buffer STDS A with granule ("1 month" or 5)<br />
tshift(A, size) Shift STDS A with granule ("1 month" or 5)<br />
tsnap(A) Snap time instances and intervals of STDS A<br />
</pre></div><br />
<br />
<h3>Examples: </h3><br />
<br />
Select all maps from space time dataset A which have equal time stamps <br />
with space time dataset B and C and are ealier that Jan. 1. 2005 and <br />
store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(start_date() < "2005-01-01", A : B : C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset A which contains more than three<br />
maps of space time dataset B, else select maps from C with time<br />
stamps that are not equal to A and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(A {contain, #} B > 3, A {contain, :} B, C)<br />
</pre></div><br />
<br />
Select all maps from space time dataset B which are during the temporal <br />
buffered space time dataset A with a map interval of three days, else<br />
select maps from C and store them in space time dataset D.<br />
<div class="code"><pre><br />
D = if(contain, td(buff_t(A, "1 days")) == 3, B, C)<br />
</pre></div><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || {{done}}<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || {{done}}<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || in progress<br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
== Week 9 - 2012-07-26 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented functions for temporal operators into the temporal algebra.<br />
* Finsihed the module t.select.<br />
* Wrote the manual page for t.select.<br />
* Started to implement vector operations into the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue documentation of the GRASS module t.select and the integration of the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19390GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-07-26T15:58:15Z<p>Mastho: /* Weekly Reports */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || {{done}}<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || {{done}}<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || in progress<br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
== Week 9 - 2012-07-26 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implemented functions for temporal operators into the temporal algebra.<br />
* Finsihed the module t.select.<br />
* Wrote the manual page for t.select.<br />
* Started to implement vector operations into the temporal algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue documentation of the GRASS module t.select and the integration of the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems occured.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19389GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-07-26T15:52:40Z<p>Mastho: /* Project plan */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || {{done}}<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || {{done}}<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || in progress<br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19240GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-07-19T14:00:56Z<p>Mastho: /* What did I do this week? */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || in progress<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || in progress<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || <br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19239GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-07-19T13:55:13Z<p>Mastho: /* What will I be working on next week? */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || in progress<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || in progress<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || <br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Added several temporal functions like start_date(), end_time(), start_datetime().<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select. Start to integrate the vector operations into the temporal vector algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19238GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-07-19T13:53:50Z<p>Mastho: /* Weekly Reports */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || in progress<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || in progress<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || <br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
== Week 8 - 2012-07-19 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Participation in the GRASS community sprint in Prague.<br />
* Discussing and working intensively on the temporal algebra.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Added several temporal functions like start_date(), end_time(), start_datetime().<br />
* Implemented topological relationships for if-statements.<br />
* Finished to implement the hash-operator (#) for map counting in conditional statements.<br />
* New module t.select alpha version in repository ready for testing.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Testing and documentation of the GRASS module t.select.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Due to direct contact to GRASS developers at the meeting in Prague all problems could be solved.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=Talk:GRASS_Community_Sprint_Prague_2013&diff=19216Talk:GRASS Community Sprint Prague 20132013-07-17T17:05:37Z<p>Mastho: /* Thomas Leppelt */</p>
<hr />
<div>== Participant comments and plans ==<br />
<br />
...<br />
<br />
=== Joint efforts ===<br />
<br />
(see [[GRASS_Community_Sprint_Prague_2013#In_person|here]] for participants' names)<br />
<br />
* Creating 3D vector test data (for 3D interpolation) - ES, SG, MN<br />
* Added [[Image_processing#General_introduction|General introduction]] (based on manual of G7/i.vi by Yann Chemin) - MN, MN, YC<br />
* Discussions on Bundle Block Adjustments - YC, ST<br />
* wxGUI refactoring - AP, VP<br />
* Presentation of state of image processing in GRASS 7 - YC, MN<br />
* Presentation of state of Temporal GIS Algebra in GRASS 7 - SG, TL<br />
* ISIS-GRASS bridge port to GRASS7 - YC, VP, ML, MN<br />
* Discussions on potential integration of Rasdaman software as raster data backend - SG, YC, and Jachym (virtually)<br />
* Presentation on vector conflation - TF with discussion<br />
* ...<br />
<br />
=== Individual Reports ===<br />
<br />
Here the (very incomplete) list of individual efforts:<br />
<br />
==== Martin Landa ====<br />
<br />
* Community Sprint organization<br />
* OSGeo4W GRASS 6.4.3RC4 package published<br />
* Fix {{cmd|v.pack|version=70}} on MS Windows, {{rev|57117}}<br />
* Fix {{cmd|v.unpack|version=70}} on MS Windows, {{rev|57121}}<br />
* Working on updated version of `msys` and `msys-dev` osgeo4w package<br />
<br />
==== Markus Neteler ====<br />
<br />
* Community Sprint Budget management (available on request)<br />
* r.wf Addon fixed: {{rev|57075}} and {{rev|57076}}<br />
* r.ipso Addon fixed: {{rev|57077}}<br />
* Draft Doxygen'iation of the CDHC [http://grass.osgeo.org/programming7/cdhclib.html library for testing normality & exponentiality]<br />
* Added [[Image_processing#General_introduction|General introduction]] to the image processing wiki/manual page (based on manual of G7/i.vi by Yann Chemin) - MN, MN, YC<br />
* Backport of i.latlong to GRASS 6 (Addon) in {{rev|57191}}.<br />
* screenshots for example in new module v.surf.mass (see Markus Metz entry)<br />
<br />
==== Yann Chemin ====<br />
<br />
* ISIS-GRASS bridge port to GRASS7 (with Vaclav, Martin and MarkusN)<br />
If ISIS (http://isis.astrogeology.usgs.gov) is installed, <br />
GRASS will load it in the background,<br />
the banner and prompt will change to ISIS-GRASS.<br />
Both ISIS and GRASS commands are available at the ISIS-GRASS prompt.<br />
<br />
* g.isis3mt exports a ISIS3 template from current location, ported into GRASS 7<br />
<br />
* Tested direct access of ISIS3 data into G7, r.in.gdal and r.external both work (tested Mars MOLA and Dawn test_datasets)<br />
<br />
* Discussed with Soeren, Vaclav and Jachym about Rasdaman, Voxel lib and Raster handling in Grass 8, we agreed on investigating handling, interfaces and performances.<br />
<br />
* Went through the Bundle Block Adjustment files with Stepan<br />
<br />
* Landsat 7 chain processing using pyGRASS goes in testing mode with MarkusN and Soeren<br />
<br />
* Worked more on r.crater<br />
<br />
==== Margherita Di Leo ====<br />
<br />
* r.basin ported to G7 {{rev|57091}}, {{rev|57096}}<br />
* r.basin html fixed {{rev|57110}}<br />
<br />
==== Markus Metz ====<br />
<br />
* r.stream.* modules: clean up before moving from addons to trunk {{rev|57151}}, {{rev|57152}}<br />
* GRASS wiki image processing update (MM, MN, YC)<br />
* standardizing options for v.db.* and db.* modules, updating respective manuals<br />
* new module [[AddOns/GRASS7/vector#v.surf.mass|v.surf.mass]] for Tobler's pycnophylactic area interpolation {{rev|57172}} ([http://svn.osgeo.org/grass/grass-addons/grass7/vector/v.surf.mass/v.surf.mass.html manual page])<br />
<br />
==== Anne Ghisla aka aghisla ====<br />
<br />
* Google Summer of Code live discussions<br />
* v.krige fixed in G7 {{rev|57146}} and following<br />
<br />
==== Sören Gebbert aka huhabla ====<br />
<br />
* Google Summer of Code Temporal Algebra presentation and implementation support<br />
* Discussion of RASDAMAN GRASS integration<br />
* Discussion and implementation of the new temporal module t.rast.accumulate and the use of a modified version of r.gdd (implemented by Markus Metz) instead of r.mapcalc<br />
* Writing and updating of many temporal modules manual pages<br />
* Implementing a prototype that uses Python multiprocessing and a new display C-library function derived from g.pnmcomp to speedup the image composition in the wx GUI<br />
<br />
==== Stepan Turek ====<br />
<br />
* Working on Google Summer of Code project <br />
* Went through the Bundle Block Adjustment files with Yann<br />
* Released source code of scatter plot backend to baclend {{rev|57180}} and turns backend {{rev|57179}}<br />
* Discussed GSoC with Martin and Soren<br />
<br />
==== Thomas Leppelt ====<br />
<br />
* Working on GSoC Project: Temporal Algebra<br />
* Discussing the algebra concept.<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Added several temporal functions like start_date(), end_time(), start_datetime().<br />
* Implemented topological relationships for if-statements.<br />
* Added topological relations for comparison operators in conditional statements.<br />
* Finished to implement the hash-operator (#) for map counting.<br />
* New module t.select alpha version in repository ready for testing. [http://grasswiki.osgeo.org/wiki/GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS GSOC-wiki]<br />
<br />
==== Milena Nowotarska ====<br />
<br />
* GUI translation to Polish {{rev|57166}}<br />
* i18n fixes<br />
* winGRASS testing<br />
<br />
==== Anna Petrasova ====<br />
<br />
* attempts to compile wxPython with wxGTK3/Broadway (HTML5) backend, so far not successfull, see [http://wxpython-users.1045709.n5.nabble.com/wxPython-with-wxGTK3-Broadway-HTML5-based-backend-td5718030.html discussion]<br />
* wxGUI refactoring<br />
* wxGUI design<br />
* toolboxes: discussion, adding <addons> tag<br />
<br />
==== Vaclav Petras ====<br />
<br />
* compiling wxPython with wxGTK3/Broadway with Anna<br />
* discussion of Rasdaman GRASS integration<br />
* wxGUI refactoring<br />
* wxGUI design<br />
* toolboxes: discussion<br />
* ISIS-GRASS bridge port to GRASS7 with Yann<br />
* discussing wxGUI programming with Stepan<br />
* tests for toolboxes<br />
<br />
==== Eva Stopková ====<br />
* debugged plotting variogram output in module v.kriging (not published yet)<br />
* improved and debugged other functions of module v.kriging<br />
<br />
* discussion about kriging methods in GRASS GIS with Anne G.<br />
* discussion about optimalization and testing modules (not published yet) v.kriging (2D/3D kriging) and v.nna (2D/3D Nearest Neighbour Analysis) with Marcus N. and Soeren G.<br />
* discussion about 3D kriging, 3D Nearest Neighbour Analysis and possibilieties of future work on the modules with Helena M.<br />
<br />
* numerical testing of v.kriging: <br />
** prepared inputs<br />
** fixing the bugs<br />
<br />
==== Tereza Fiedlerová ====<br />
* learning something about GRASS GIS vector modules <br />
* discussion about own QGIS plugin and C++ library for vector conflation and its possible implementation to GRASS<br />
* beginning to write C API for vector conflation library (needed for GRASS implementation)<br />
<br />
<br />
== Video-conferencing options ==<br />
<br />
Q: is Google Hangouts smartphones only?<br />
: ''not sure, but I'm pretty sure you can get a web browser plugin for all major desktop OSs''<br />
<br />
Q: do you have to be signed up with a Google+ social media account?<br />
: ''in theory no, but in practice they strongly funnel you that way''<br />
<br />
Q: is Jitsi on a desktop computer compatible with G+?<br />
: ''at the text chat level, yes. video and voice via Google Talk, reported to work with Voice, not sure about video''<br />
<br />
; [http://www.jitsi.org Jitsi]<br />
: ''It is compatible with GoogleTalk instant messaging (and most other instant messaging including the XMPP RFC like Facebook; Skype is the notable one that it doesn't work with), not sure about GoogleTalk's voice calls, I'd give that a 80% chance of working.<br />
: An interesting side-project Jisti offers its own work-alike free multi-person video chat for XMPP(Jabber compatibles) which is not limited to 10 people: [https://jitsi.org/Projects/JitsiVideobridge VideoBridge]. Given enough bandwidth and a modern desktop CPU acting as the bridge server, you can have someone in a G+ hangout share their desktop to pass through the other members of the video hangout.<br />
: Also there's a functional alpha-release Android client.<br />
: For Jitsi <-> Jitsi video you may need a valid XMPP account. Many (federated in a single grid) providers for that, so it doesn't matter much who. Jitsi run a simple registry at http://jit.si<br />
: All quite interesting possiblies and the development is quite active -- but is it there yet? I'm not sure, probably a not far away "almost"; if so, perhaps we could run the bridge on Adhoc for a few days (can run as an unprivilidged user, needs Java 6, chat "host" user needs shell access to set magic pass word and get the assigned port numbers to plug into their client), or perhaps host it at fsv.cvut.cz? (i.e. locate it at the shortest hop to max number of participants using it) --HB''</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=Talk:GRASS_Community_Sprint_Prague_2013&diff=19207Talk:GRASS Community Sprint Prague 20132013-07-17T10:15:02Z<p>Mastho: /* Thomas Leppelt */</p>
<hr />
<div>== Participant comments and plans ==<br />
<br />
...<br />
<br />
=== Joint efforts ===<br />
<br />
(see [[GRASS_Community_Sprint_Prague_2013#In_person|here]] for participants' names)<br />
<br />
* Creating 3D vector test data (for 3D interpolation) - ES, SG, MN<br />
* Added [[Image_processing#General_introduction|General introduction]] (based on manual of G7/i.vi by Yann Chemin) - MN, MN, YC<br />
* Discussions on Bundle Block Adjustments - YC, ST<br />
* wxGUI refactoring - AP, VP<br />
* Presentation of state of image processing in GRASS 7 - YC, MN<br />
* Presentation of state of Temporal GIS Algebra in GRASS 7 - SG, TL<br />
* ISIS-GRASS bridge port to GRASS7 - YC, VP, ML, MN<br />
* Discussions on potential integration of Rasdaman software as raster data backend - SG, YC, and Jachym (virtually)<br />
* Presentation on vector conflation - TF with discussion<br />
* ...<br />
<br />
=== Individual Reports ===<br />
<br />
Here the (very incomplete) list of individual efforts:<br />
<br />
==== Martin Landa ====<br />
<br />
* Community Sprint organization<br />
* OSGeo4W GRASS 6.4.3RC4 package published<br />
* Fix {{cmd|v.pack|version=70}} on MS Windows, {{rev|57117}}<br />
* Fix {{cmd|v.unpack|version=70}} on MS Windows, {{rev|57121}}<br />
<br />
==== Markus Neteler ====<br />
<br />
* Community Sprint Budget management (available on request)<br />
* r.wf Addon fixed: {{rev|57075}} and {{rev|57076}}<br />
* r.ipso Addon fixed: {{rev|57077}}<br />
* Draft Doxygen'iation of the CDHC [http://grass.osgeo.org/programming7/cdhclib.html library for testing normality & exponentiality]<br />
* Added [[Image_processing#General_introduction|General introduction]] to the image processing wiki/manual page (based on manual of G7/i.vi by Yann Chemin) - MN, MN, YC<br />
<br />
==== Yann Chemin ====<br />
<br />
* ISIS-GRASS bridge port to GRASS7 (with Vaclav, Martin and MarkusN)<br />
If ISIS (http://isis.astrogeology.usgs.gov) is installed, <br />
GRASS will load it in the background,<br />
the banner and prompt will change to ISIS-GRASS.<br />
Both ISIS and GRASS commands are available at the ISIS-GRASS prompt.<br />
<br />
* g.isis3mt exports a ISIS3 template from current location, ported into GRASS 7<br />
<br />
* Tested direct access of ISIS3 data into G7, r.in.gdal and r.external both work (tested Mars MOLA and Dawn test_datasets)<br />
<br />
* Discussed with Soeren, Vaclav and Jachym about Rasdaman, Voxel lib and Raster handling in Grass 8, we agreed on investigating handling, interfaces and performances.<br />
<br />
* Went through the Bundle Block Adjustment files with Stepan<br />
<br />
* Landsat 7 chain processing using pyGRASS goes in testing mode with MarkusN and Soeren<br />
<br />
* Worked more on r.crater<br />
<br />
==== Margherita Di Leo ====<br />
<br />
* r.basin ported to G7 {{rev|57091}}, {{rev|57096}}<br />
* r.basin html fixed {{rev|57110}}<br />
<br />
==== Markus Metz ====<br />
<br />
* r.stream.* modules: clean up before moving from addons to trunk {{rev|57151}}, {{rev|57152}}<br />
* GRASS wiki image processing update (MM, MN, YC)<br />
* standardizing options for v.db.* and db.* modules, updating respective manuals<br />
* pycnophylactic area interpolation {{rev|57172}}<br />
<br />
==== Anne Ghisla aka aghisla ====<br />
<br />
* Google Summer of Code live discussions<br />
* v.krige fixed in G7 {{rev|57146}} and following<br />
<br />
==== Sören Gebbert aka huhabla ====<br />
<br />
* Google Summer of Code Temporal Algebra presentation and implementation support<br />
* Discussion of RASDAMAN GRASS integration<br />
* Discussion and implementation of the new temporal module t.rast.accumulate and the use of a modified version of r.gdd (implemented by Markus Metz) instead of r.mapcalc<br />
* Writing and updating of many temporal modules manual pages<br />
* Implementing a prototype that uses Python multiprocessing and a new display C-library function derived from g.pnmcomp to speedup the image composition in the wx GUI<br />
<br />
==== Stepan Turek ====<br />
<br />
* Working on Google Summer of Code project <br />
* Went through the Bundle Block Adjustment files with Yann<br />
* Released source code of scatter plot backend to baclend {{rev|57180}} and turns backend {{rev|57179}}<br />
* Discussed GSoC with Martin and Soren<br />
<br />
==== Thomas Leppelt ====<br />
<br />
* Working on GSoC Project: Temporal Algebra<br />
* Discussing the algebra concept.<br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Added several temporal functions like start_date(), end_time(), start_datetime().<br />
* Implemented topological relationships for if-statements.<br />
* Added topological relations for comparison operators in conditional statements.<br />
* Started to implement the hash-operator (#) for map counting.<br />
* New module t.select almost finished.<br />
<br />
==== Milena Nowotarska ====<br />
<br />
* GUI translation to Polish {{rev|57166}}<br />
* i18n fixes<br />
* winGRASS testing<br />
<br />
==== Anna Petrasova ====<br />
<br />
* attempts to compile wxPython with wxGTK3/Broadway (HTML5) backend, so far not successfull, see [http://wxpython-users.1045709.n5.nabble.com/wxPython-with-wxGTK3-Broadway-HTML5-based-backend-td5718030.html discussion]<br />
* wxGUI refactoring<br />
* wxGUI design<br />
* toolboxes: discussion, adding <addons> tag<br />
<br />
==== Vaclav Petras ====<br />
<br />
* compiling wxPython with wxGTK3/Broadway with Anna<br />
* discussion of Rasdaman GRASS integration<br />
* wxGUI refactoring<br />
* wxGUI design<br />
* toolboxes: discussion<br />
* ISIS-GRASS bridge port to GRASS7 with Yann<br />
* discussing wxGUI programming with Stepan<br />
* tests for toolboxes<br />
<br />
==== Eva Stopková ====<br />
* debug of plotting variogram output in module v.kriging (not published yet)<br />
* discussion about kriging methods in GRASS GIS with Anne<br />
* discussion about optimalization and testing modules (not published yet) v.kriging (2D/3D kriging) and v.nna (2D/3D Nearest Neighbour Analysis) with Marcus N. and Soeren G.<br />
* improving and debugging other functions of module v.kriging<br />
* numerical testing of v.kriging<br />
<br />
==== Tereza Fiedlerová ====<br />
* learning something about GRASS GIS vector modules <br />
* discussion about own QGIS plugin and C++ library for vector conflation and its possible implementation to GRASS<br />
* beginning to write C API for vector conflation library (needed for GRASS implementation)<br />
<br />
<br />
== Video-conferencing options ==<br />
<br />
Q: is Google Hangouts smartphones only?<br />
: ''not sure, but I'm pretty sure you can get a web browser plugin for all major desktop OSs''<br />
<br />
Q: do you have to be signed up with a Google+ social media account?<br />
: ''in theory no, but in practice they strongly funnel you that way''<br />
<br />
Q: is Jitsi on a desktop computer compatible with G+?<br />
: ''at the text chat level, yes. video and voice via Google Talk, reported to work with Voice, not sure about video''<br />
<br />
; [http://www.jitsi.org Jitsi]<br />
: ''It is compatible with GoogleTalk instant messaging (and most other instant messaging including the XMPP RFC like Facebook; Skype is the notable one that it doesn't work with), not sure about GoogleTalk's voice calls, I'd give that a 80% chance of working.<br />
: An interesting side-project Jisti offers its own work-alike free multi-person video chat for XMPP(Jabber compatibles) which is not limited to 10 people: [https://jitsi.org/Projects/JitsiVideobridge VideoBridge]. Given enough bandwidth and a modern desktop CPU acting as the bridge server, you can have someone in a G+ hangout share their desktop to pass through the other members of the video hangout.<br />
: Also there's a functional alpha-release Android client.<br />
: For Jitsi <-> Jitsi video you may need a valid XMPP account. Many (federated in a single grid) providers for that, so it doesn't matter much who. Jitsi run a simple registry at http://jit.si<br />
: All quite interesting possiblies and the development is quite active -- but is it there yet? I'm not sure, probably a not far away "almost"; if so, perhaps we could run the bridge on Adhoc for a few days (can run as an unprivilidged user, needs Java 6, chat "host" user needs shell access to set magic pass word and get the assigned port numbers to plug into their client), or perhaps host it at fsv.cvut.cz? (i.e. locate it at the shortest hop to max number of participants using it) --HB''</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=Talk:GRASS_Community_Sprint_Prague_2013&diff=19206Talk:GRASS Community Sprint Prague 20132013-07-17T10:14:00Z<p>Mastho: /* Thomas Leppelt */</p>
<hr />
<div>== Participant comments and plans ==<br />
<br />
...<br />
<br />
=== Joint efforts ===<br />
<br />
(see [[GRASS_Community_Sprint_Prague_2013#In_person|here]] for participants' names)<br />
<br />
* Creating 3D vector test data (for 3D interpolation) - ES, SG, MN<br />
* Added [[Image_processing#General_introduction|General introduction]] (based on manual of G7/i.vi by Yann Chemin) - MN, MN, YC<br />
* Discussions on Bundle Block Adjustments - YC, ST<br />
* wxGUI refactoring - AP, VP<br />
* Presentation of state of image processing in GRASS 7 - YC, MN<br />
* Presentation of state of Temporal GIS Algebra in GRASS 7 - SG, TL<br />
* ISIS-GRASS bridge port to GRASS7 - YC, VP, ML, MN<br />
* Discussions on potential integration of Rasdaman software as raster data backend - SG, YC, and Jachym (virtually)<br />
* Presentation on vector conflation - TF with discussion<br />
* ...<br />
<br />
=== Individual Reports ===<br />
<br />
Here the (very incomplete) list of individual efforts:<br />
<br />
==== Martin Landa ====<br />
<br />
* Community Sprint organization<br />
* OSGeo4W GRASS 6.4.3RC4 package published<br />
* Fix {{cmd|v.pack|version=70}} on MS Windows, {{rev|57117}}<br />
* Fix {{cmd|v.unpack|version=70}} on MS Windows, {{rev|57121}}<br />
<br />
==== Markus Neteler ====<br />
<br />
* Community Sprint Budget management (available on request)<br />
* r.wf Addon fixed: {{rev|57075}} and {{rev|57076}}<br />
* r.ipso Addon fixed: {{rev|57077}}<br />
* Draft Doxygen'iation of the CDHC [http://grass.osgeo.org/programming7/cdhclib.html library for testing normality & exponentiality]<br />
* Added [[Image_processing#General_introduction|General introduction]] to the image processing wiki/manual page (based on manual of G7/i.vi by Yann Chemin) - MN, MN, YC<br />
<br />
==== Yann Chemin ====<br />
<br />
* ISIS-GRASS bridge port to GRASS7 (with Vaclav, Martin and MarkusN)<br />
If ISIS (http://isis.astrogeology.usgs.gov) is installed, <br />
GRASS will load it in the background,<br />
the banner and prompt will change to ISIS-GRASS.<br />
Both ISIS and GRASS commands are available at the ISIS-GRASS prompt.<br />
<br />
* g.isis3mt exports a ISIS3 template from current location, ported into GRASS 7<br />
<br />
* Tested direct access of ISIS3 data into G7, r.in.gdal and r.external both work (tested Mars MOLA and Dawn test_datasets)<br />
<br />
* Discussed with Soeren, Vaclav and Jachym about Rasdaman, Voxel lib and Raster handling in Grass 8, we agreed on investigating handling, interfaces and performances.<br />
<br />
* Went through the Bundle Block Adjustment files with Stepan<br />
<br />
* Landsat 7 chain processing using pyGRASS goes in testing mode with MarkusN and Soeren<br />
<br />
* Worked more on r.crater<br />
<br />
==== Margherita Di Leo ====<br />
<br />
* r.basin ported to G7 {{rev|57091}}, {{rev|57096}}<br />
* r.basin html fixed {{rev|57110}}<br />
<br />
==== Markus Metz ====<br />
<br />
* r.stream.* modules: clean up before moving from addons to trunk {{rev|57151}}, {{rev|57152}}<br />
* GRASS wiki image processing update (MM, MN, YC)<br />
* standardizing options for v.db.* and db.* modules, updating respective manuals<br />
* pycnophylactic area interpolation {{rev|57172}}<br />
<br />
==== Anne Ghisla aka aghisla ====<br />
<br />
* Google Summer of Code live discussions<br />
* v.krige fixed in G7 {{rev|57146}} and following<br />
<br />
==== Sören Gebbert aka huhabla ====<br />
<br />
* Google Summer of Code Temporal Algebra presentation and implementation support<br />
* Discussion of RASDAMAN GRASS integration<br />
* Discussion and implementation of the new temporal module t.rast.accumulate and the use of a modified version of r.gdd (implemented by Markus Metz) instead of r.mapcalc<br />
* Writing and updating of many temporal modules manual pages<br />
* Implementing a prototype that uses Python multiprocessing and a new display C-library function derived from g.pnmcomp to speedup the image composition in the wx GUI<br />
<br />
==== Stepan Turek ====<br />
<br />
* Working on Google Summer of Code project <br />
* Went through the Bundle Block Adjustment files with Yann<br />
* Released source code of scatter plot backend to baclend {{rev|57180}} and turns backend {{rev|57179}}<br />
* Discussed GSoC with Martin and Soren<br />
<br />
==== Thomas Leppelt ====<br />
<br />
* Working on GSoC Project: Temporal Algebra <br />
* Implemented functions for if-statements in the temporal algebra.<br />
* Added several temporal functions like start_date(), end_time(), start_datetime().<br />
* Implemented topological relationships for if-statements.<br />
* Added topological relations for comparison operators in conditional statements.<br />
* Started to implement the hash-operator (#) for map counting.<br />
* New module t.select almost finished.<br />
<br />
==== Milena Nowotarska ====<br />
<br />
* GUI translation to Polish {{rev|57166}}<br />
* i18n fixes<br />
* winGRASS testing<br />
<br />
==== Anna Petrasova ====<br />
<br />
* attempts to compile wxPython with wxGTK3/Broadway (HTML5) backend, so far not successfull, see [http://wxpython-users.1045709.n5.nabble.com/wxPython-with-wxGTK3-Broadway-HTML5-based-backend-td5718030.html discussion]<br />
* wxGUI refactoring<br />
* wxGUI design<br />
* toolboxes: discussion, adding <addons> tag<br />
<br />
==== Vaclav Petras ====<br />
<br />
* compiling wxPython with wxGTK3/Broadway with Anna<br />
* discussion of Rasdaman GRASS integration<br />
* wxGUI refactoring<br />
* wxGUI design<br />
* toolboxes: discussion<br />
* ISIS-GRASS bridge port to GRASS7 with Yann<br />
* discussing wxGUI programming with Stepan<br />
* tests for toolboxes<br />
<br />
==== Eva Stopková ====<br />
* debug of plotting variogram output in module v.kriging (not published yet)<br />
* discussion about kriging methods in GRASS GIS with Anne<br />
* discussion about optimalization and testing modules (not published yet) v.kriging (2D/3D kriging) and v.nna (2D/3D Nearest Neighbour Analysis) with Marcus N. and Soeren G.<br />
* improving and debugging other functions of module v.kriging<br />
* numerical testing of v.kriging<br />
<br />
==== Tereza Fiedlerová ====<br />
* learning something about GRASS GIS vector modules <br />
* discussion about own QGIS plugin and C++ library for vector conflation and its possible implementation to GRASS<br />
* beginning to write C API for vector conflation library (needed for GRASS implementation)<br />
<br />
<br />
== Video-conferencing options ==<br />
<br />
Q: is Google Hangouts smartphones only?<br />
: ''not sure, but I'm pretty sure you can get a web browser plugin for all major desktop OSs''<br />
<br />
Q: do you have to be signed up with a Google+ social media account?<br />
: ''in theory no, but in practice they strongly funnel you that way''<br />
<br />
Q: is Jitsi on a desktop computer compatible with G+?<br />
: ''at the text chat level, yes. video and voice via Google Talk, reported to work with Voice, not sure about video''<br />
<br />
; [http://www.jitsi.org Jitsi]<br />
: ''It is compatible with GoogleTalk instant messaging (and most other instant messaging including the XMPP RFC like Facebook; Skype is the notable one that it doesn't work with), not sure about GoogleTalk's voice calls, I'd give that a 80% chance of working.<br />
: An interesting side-project Jisti offers its own work-alike free multi-person video chat for XMPP(Jabber compatibles) which is not limited to 10 people: [https://jitsi.org/Projects/JitsiVideobridge VideoBridge]. Given enough bandwidth and a modern desktop CPU acting as the bridge server, you can have someone in a G+ hangout share their desktop to pass through the other members of the video hangout.<br />
: Also there's a functional alpha-release Android client.<br />
: For Jitsi <-> Jitsi video you may need a valid XMPP account. Many (federated in a single grid) providers for that, so it doesn't matter much who. Jitsi run a simple registry at http://jit.si<br />
: All quite interesting possiblies and the development is quite active -- but is it there yet? I'm not sure, probably a not far away "almost"; if so, perhaps we could run the bridge on Adhoc for a few days (can run as an unprivilidged user, needs Java 6, chat "host" user needs shell access to set magic pass word and get the assigned port numbers to plug into their client), or perhaps host it at fsv.cvut.cz? (i.e. locate it at the shortest hop to max number of participants using it) --HB''</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=Talk:GRASS_Community_Sprint_Prague_2013&diff=19180Talk:GRASS Community Sprint Prague 20132013-07-15T17:18:49Z<p>Mastho: /* Individual Reports */</p>
<hr />
<div>== Participant comments and plans ==<br />
<br />
...<br />
<br />
=== Joint efforts ===<br />
<br />
(see [[GRASS_Community_Sprint_Prague_2013#In_person|here]] for participants' names)<br />
<br />
* Creating 3D vector test data (for 3D interpolation) - ES, SG, MN<br />
* Added [[Image_processing#General_introduction|General introduction]] (based on manual of G7/i.vi by Yann Chemin) - MN, MN, YC<br />
* Discussions on Bundle Block Adjustments - YC, ST<br />
* wxGUI refactoring - AP, VP<br />
* Presentation of state of image processing in GRASS 7 - YC, MN<br />
* Presentation of state of Temporal GIS Algebra in GRASS 7 - SG, TL<br />
* ISIS-GRASS bridge port to GRASS7 - YC, VP, ML, MN<br />
* Discussions on potential integration of Rasdaman software as raster data backend - SG, YC, and Jachym (virtually)<br />
* Presentation on vector conflation - TF with discussion<br />
* ...<br />
<br />
=== Individual Reports ===<br />
<br />
Here the (very incomplete) list of individual efforts:<br />
<br />
==== Martin Landa ====<br />
<br />
* Community Sprint organization<br />
* OSGeo4W GRASS 6.4.3RC4 package published<br />
* Fix {{cmd|v.pack|version=70}} on MS Windows, {{rev|57117}}<br />
* Fix {{cmd|v.unpack|version=70}} on MS Windows, {{rev|57121}}<br />
<br />
==== Markus Neteler ====<br />
<br />
* Community Sprint Budget management (available on request)<br />
* r.wf Addon fixed: {{rev|57075}} and {{rev|57076}}<br />
* r.ipso Addon fixed: {{rev|57077}}<br />
* Draft Doxygen'iation of the CDHC [http://grass.osgeo.org/programming7/cdhclib.html library for testing normality & exponentiality]<br />
* Added [[Image_processing#General_introduction|General introduction]] (based on manual of G7/i.vi by Yann Chemin) - MN, MN, YC<br />
<br />
==== Yann Chemin ====<br />
<br />
* ISIS-GRASS bridge port to GRASS7 (with Vaclav, Martin and MarkusN)<br />
If ISIS (http://isis.astrogeology.usgs.gov) is installed, <br />
GRASS will load it in the background,<br />
the banner and prompt will change to ISIS-GRASS.<br />
Both ISIS and GRASS commands are available at the ISIS-GRASS prompt.<br />
<br />
* g.isis3mt exports a ISIS3 template from current location, ported into GRASS 7<br />
<br />
* Tested direct access of ISIS3 data into G7, r.in.gdal and r.external both work (tested Mars MOLA and Dawn test_datasets)<br />
<br />
* Discussed with Soeren, Vaclav and Jachym about Rasdaman, Voxel lib and Raster handling in Grass 8, we agreed on investigating handling, interfaces and performances.<br />
<br />
* Went through the Bundle Block Adjustment files with Stepan<br />
<br />
* Landsat 7 chain processing using pyGRASS goes in testing mode with MarkusN and Soeren<br />
<br />
* Worked more on r.crater<br />
<br />
==== Margherita Di Leo ====<br />
<br />
* r.basin ported to G7 {{rev|57091}}, {{rev|57096}}<br />
* r.basin html fixed {{rev|57110}}<br />
<br />
==== Markus Metz ====<br />
<br />
* r.stream.* modules: clean up before moving from addons to trunk {{rev|57151}}, {{rev|57152}}<br />
* GRASS wiki image processing update (MM, MN, YC)<br />
<br />
==== Anne Ghisla aka aghisla ====<br />
<br />
* Google Summer of Code live discussions<br />
* v.krige fixed in G7 {{rev|57146}} and following<br />
<br />
==== Sören Gebbert aka huhabla ====<br />
<br />
* Google Summer of Code Temporal Algebra presentation and implementation support<br />
* Discussion of RASDAMAN GRASS integration<br />
* Discussion and implementation of the new temporal module t.rast.accumulate and the use of a modified version of r.gdd (implemented by Markus Metz) instead of r.mapcalc<br />
* Writing and updating of many temporal modules manual pages<br />
<br />
==== Stepan Turek ====<br />
<br />
* Working on Google Summer of Code project <br />
* Went through the Bundle Block Adjustment files with Yann<br />
<br />
==== Thomas Leppelt ====<br />
<br />
* Working on GSoC Project: Temporal Algebra <br />
* Implementing functions for if-statements in the temporal algebra<br />
<br />
== Video-conferencing options ==<br />
<br />
Q: is Google Hangouts smartphones only?<br />
: ''not sure, but I'm pretty sure you can get a web browser plugin for all major desktop OSs''<br />
<br />
Q: do you have to be signed up with a Google+ social media account?<br />
: ''in theory no, but in practice they strongly funnel you that way''<br />
<br />
Q: is Jitsi on a desktop computer compatible with G+?<br />
: ''at the text chat level, yes. video and voice via Google Talk, reported to work with Voice, not sure about video''<br />
<br />
; [http://www.jitsi.org Jitsi]<br />
: ''It is compatible with GoogleTalk instant messaging (and most other instant messaging including the XMPP RFC like Facebook; Skype is the notable one that it doesn't work with), not sure about GoogleTalk's voice calls, I'd give that a 80% chance of working.<br />
: An interesting side-project Jisti offers its own work-alike free multi-person video chat for XMPP(Jabber compatibles) which is not limited to 10 people: [https://jitsi.org/Projects/JitsiVideobridge VideoBridge]. Given enough bandwidth and a modern desktop CPU acting as the bridge server, you can have someone in a G+ hangout share their desktop to pass through the other members of the video hangout.<br />
: Also there's a functional alpha-release Android client.<br />
: For Jitsi <-> Jitsi video you may need a valid XMPP account. Many (federated in a single grid) providers for that, so it doesn't matter much who. Jitsi run a simple registry at http://jit.si<br />
: All quite interesting possiblies and the development is quite active -- but is it there yet? I'm not sure, probably a not far away "almost"; if so, perhaps we could run the bridge on Adhoc for a few days (can run as an unprivilidged user, needs Java 6, chat "host" user needs shell access to set magic pass word and get the assigned port numbers to plug into their client), or perhaps host it at fsv.cvut.cz? (i.e. locate it at the shortest hop to max number of participants using it) --HB''</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19128GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-07-13T08:10:46Z<p>Mastho: /* Project plan */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || {{done}}<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || {{done}}<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || in progress<br />
|-<br />
|July 19 || Writing documentation for temporal algebra || in progress<br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || <br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19126GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-07-13T08:00:54Z<p>Mastho: /* What will I be working on next week? */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || in progress<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || in progress<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || <br />
|-<br />
|July 19 || Writing documentation for temporal algebra || <br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || <br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensively on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19125GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-07-13T07:47:39Z<p>Mastho: /* Weekly Reports */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || in progress<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || in progress<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || <br />
|-<br />
|July 19 || Writing documentation for temporal algebra || <br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || <br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
== Week 7 - 2012-07-12 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions for temporal buffering, snapping and shifting.<br />
* Add global temporal variables into the algebra (td(), start_time, end_time, ...)<br />
* Started to integrate conditional statements into the algebra.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
This week I participate in the GRASS community sprint in Prague. Discussing and working intensivly on the temporal algebra for the next six days.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
Only minor problems.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19089GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-07-05T19:49:03Z<p>Mastho: /* Weekly Reports */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || in progress<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || in progress<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || <br />
|-<br />
|July 19 || Writing documentation for temporal algebra || <br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || <br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
== Week 6 - 2012-07-05 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Implement functions to compare space time datasets by their topology and to perform temporal selection on raster and vector datasets.<br />
* Create Module t.select for temporal selection.<br />
* Changed some functionalities in the temporal algebra concept.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra functions like temporal buffering, snapping and shifting.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
No big Problems this week<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19058GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-06-28T10:05:43Z<p>Mastho: /* What did I do this week? */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || in progress<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || in progress<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || <br />
|-<br />
|July 19 || Writing documentation for temporal algebra || <br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || <br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions.<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19057GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-06-28T10:05:28Z<p>Mastho: /* What did I do this week? */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || in progress<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || in progress<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || <br />
|-<br />
|July 19 || Writing documentation for temporal algebra || <br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || <br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions.<br />
* Utilize TGIS methods to evaluate temporal selection expressions .<br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19056GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-06-28T09:58:34Z<p>Mastho: </p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || in progress<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || in progress<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || <br />
|-<br />
|July 19 || Writing documentation for temporal algebra || <br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || <br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions. <br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.<br />
<br />
= Repository =<br />
The code for this project can be found in a svn repository at code.google: [https://code.google.com/p/grass-gis-temporal-algebra/ grass-gis-temporal-algebra]</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19055GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-06-28T09:54:40Z<p>Mastho: /* Temporal Algebra concept */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= Temporal Algebra concept=<br />
An overview of the Temporal GIS Algebra concept for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here].<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || in progress<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || in progress<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || <br />
|-<br />
|July 19 || Writing documentation for temporal algebra || <br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || <br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions. <br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19054GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-06-28T09:52:49Z<p>Mastho: /* Project plan */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= Temporal Algebra concept=<br />
The concept of the Temporal GIS Algebra for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here]<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API || in progress<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || in progress<br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || <br />
|-<br />
|July 19 || Writing documentation for temporal algebra || <br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || <br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions. <br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=19053GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-06-28T09:51:57Z<p>Mastho: /* Weekly Reports */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= Temporal Algebra concept=<br />
The concept of the Temporal GIS Algebra for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here]<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API ||<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || <br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || <br />
|-<br />
|July 19 || Writing documentation for temporal algebra || <br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || <br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.<br />
<br />
== Week 5 - 2012-06-28 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Using PLY for lexical analysis of temporal expressions. <br />
* Start to implement an intern map list structure to store generated map lists, derived from temporal expressions, independently from input type (Vector, Raster).<br />
* Writing the structure for the temporal algebra and started to fill in the required methods.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Continue the implementation of the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
I try to keep track of the temporal algebra. Sometimes it gets very complex.</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=File:Vmapcalc_example2.png&diff=19000File:Vmapcalc example2.png2013-06-23T05:01:36Z<p>Mastho: Mastho uploaded a new version of &quot;File:Vmapcalc example2.png&quot;: Example for v.mapcalc</p>
<hr />
<div>Example for v.mapcalc</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=File:Vmapcalc_example1.png&diff=18999File:Vmapcalc example1.png2013-06-23T05:01:07Z<p>Mastho: Mastho uploaded a new version of &quot;File:Vmapcalc example1.png&quot;: Example for v.mapcalc</p>
<hr />
<div>Example for v.mapcalc</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=18998GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-06-22T07:17:01Z<p>Mastho: /* Notes */</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
<br />
[[File:Vmapcalc example1.png]]<br />
<br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
[[File:Vmapcalc example2.png]]<br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= Temporal Algebra concept=<br />
The concept of the Temporal GIS Algebra for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here]<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API ||<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || <br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || <br />
|-<br />
|July 19 || Writing documentation for temporal algebra || <br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || <br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=File:Vmapcalc_example2.png&diff=18997File:Vmapcalc example2.png2013-06-22T07:14:09Z<p>Mastho: Example for v.mapcalc</p>
<hr />
<div>Example for v.mapcalc</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=File:Vmapcalc_example1.png&diff=18996File:Vmapcalc example1.png2013-06-22T07:13:40Z<p>Mastho: Example for v.mapcalc</p>
<hr />
<div>Example for v.mapcalc</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=18995GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-06-22T07:06:18Z<p>Mastho: </p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= v.mapcalc =<br />
<br />
== Description ==<br />
<br />
v.mapcalc performs overlay and buffer functions on vector map layers. New vector map layers can be created which are expressions of existing vector map layers, boolean vector operations and buffer functions.<br />
<br />
== Program use ==<br />
<br />
The module expects its input as expression in the following form: <br />
<br />
<source lang="bash"><br />
result = expression <br />
</source><br />
<br />
This structure is similar to r.mapcalc, see r.mapcalc. Where result is the name of a vector map layer that will contain the result of the calculation and expression is any valid combination of boolean and buffer operations for existing vector map layers. <br />
The input is given by using the first module option expression= . This option passes a quoted expression on the command line, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="A = B"<br />
</source><br />
<br />
Where A is the new vector map layer that will be equal to the existing vector map layer B in this case. <br />
<br />
<source lang="bash"> <br />
v.mapcalc "A = B"<br />
</source><br />
<br />
Will give the same result.<br />
<br />
== Operators and functions ==<br />
The module supports the following boolean vector operations: <br />
<br />
{| {{table}}<br />
|- <br />
!Boolean Name !! Operator !! Meaning !! Precedence !! Correspondent function <br />
|- <br />
|AND || & || Intersection || 1 || (v.overlay operator=and) <br />
|- <br />
|OR || <nowiki>|</nowiki> || Union || 1 || (v.overlay operator=or) <br />
|- <br />
|DISJOINT OR || + || Disjoint union || 1 || (v.patch) <br />
|- <br />
|XOR || ^ || Symmetric difference || 1 || (v.overlay operator=xor) <br />
|- <br />
|NOT || ~ || Complement || 1 || (v.overlay operator=not) <br />
|}<br />
<br />
And vector functions:<br />
<br />
{| {{table}}<br />
|- <br />
! Function name !! Description<br />
|-<br />
| buff_p(A, size) || Buffer the points of vector map layer A with size<br />
|-<br />
| buff_l(A, size) || Buffer the lines of vector map layer A with size<br />
|-<br />
| buff_a(A, size) || Buffer the areas of vector map layer A with size<br />
|}<br />
<br />
== Notes ==<br />
As shown in the operator table above, the boolean vector operators do not have different precedence. In default setting the expression will be left associatively evaluated. To define specific precedence use parentheses around these expressions, for example: <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & B | C"<br />
</source><br />
Here the first intermediate result is the intersection of vector map layers A & B. This intermediate vector map layer is taken to create the union with vector map C to get the final result D. It represents the default behaviour of left associativity. <br />
<br />
<source lang="bash"> <br />
v.mapcalc expression="D = A & (B | C)"<br />
</source><br />
<br />
Here the first intermediate result is taken from the parenthesized union of vector map layers B | C. Afterwards the intersection of the intermediate vector map layer and A will be evaluated to get the final result vector map layer D. <br />
<br />
It should be noticed, that the order in which the operations are performed does matter. Different order of operations can lead to a different result.<br />
<br />
== Examples ==<br />
This example needed specific region setting. It should work in UTM and LL test locations. <br />
First set the regions extent and create two vector maps with one random points, respectively: <br />
<source lang="bash"> <br />
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3<br />
<br />
v.random --o -z output=point_1 n=1 seed=1 <br />
v.info point_1<br />
v.random --o -z output=point_2 n=1 seed=2 <br />
v.info point_2<br />
</source><br />
<br />
Then the vector algebra is used to create buffers around those points, cut out a subset and apply different boolean operation on the subsets in one statement: <br />
<br />
<source lang="bash"> <br />
v.mapcalc --o expr="buff_and = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) & (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_or = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) | (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_xor = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ^ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
<br />
v.mapcalc --o expr="buff_not = (buff_p(point_1, 30.0) ~ buff_p(point_1, 20.0)) ~ (buff_p(point_2, 35) ~ buff_p(point_2, 25))"<br />
</source><br />
<br />
= Temporal Algebra concept=<br />
The concept of the Temporal GIS Algebra for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here]<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API ||<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || <br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || <br />
|-<br />
|July 19 || Writing documentation for temporal algebra || <br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || <br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=18994GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-06-21T16:42:37Z<p>Mastho: </p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= Temporal Algebra concept=<br />
The concept of the Temporal GIS Algebra for Raster and Vector Data is open for discussion and can be found [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra here]<br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API ||<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || <br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || <br />
|-<br />
|July 19 || Writing documentation for temporal algebra || <br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || <br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ | google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_GSoC_2013_Temporal_GIS_Algebra_for_raster_and_vector_data_in_GRASS&diff=18993GRASS GSoC 2013 Temporal GIS Algebra for raster and vector data in GRASS2013-06-21T16:36:27Z<p>Mastho: Created page with "{{GSoC}} {{wxGUI}} ''(See also other GRASS GSoC 2013 projects)'' {| {{table}} |Student Name: || Thomas Leppelt, [http://www.ti.bund.de/..."</p>
<hr />
<div>{{GSoC}}<br />
{{wxGUI}}<br />
''(See also other [[GRASS_SoC_Ideas_2013#Accepted_Ideas|GRASS GSoC 2013 projects]])''<br />
{| {{table}}<br />
|Student Name: || Thomas Leppelt, [http://www.ti.bund.de/en/ Thünen Institute Braunschweig Germany]<br />
|-<br />
|Organization: || [http://www.osgeo.org OSGeo - Open Source Geospatial Foundation]<br />
|-<br />
| Mentor Name: || Mentor: Soeren Gebbert Backup mentor: Helena Mitasova & Michael Barton <br />
|-<br />
| Title: || '''Temporal GIS Algebra for raster and vector data in GRASS '''<br />
|-<br />
|}<br />
<br />
<br />
<br />
<br />
__TOC__<br />
<br />
=Abstract=<br />
Using the TGRASS GIS API to create spatio-temporal vector and raster algebra to process massive vector and raster datasets based on their spatio-temporal relationships.<br />
<br />
= Background =<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
= The idea =<br />
<br />
I would like to develop a temporal GIS algebra for raster and vector data in GRASS7. The idea is also posted on the GRASS SoC ideas page for 2013 (http://grasswiki.osgeo.org/wiki/GRASS_SoC_Ideas_2013).<br />
<br />
The temporal modules in GRASS are capable of managing, analysing, processing and visualizing large spatio-temporal datasets. Additionally various temporal framework properties were implemented to describe the temporal and spatial relationships for datasets. Our aim is to develop modules, that can be used to process massive vector and raster datasets based on their spatio-temporal relationships. Therefore a spatio-temporal vector and raster algebra is needed and has to be implemented into GRASS7.<br />
<br />
The project will have three new GRASS7 modules and additions to the GRASS GIS temporal library as outcome:<br />
<br />
'''v.mapcalc'''<br />
<br />
According to r.mapcalc for raster datasets, v.mapcalc will provide the functionalities of GRASS modules like v.overlay (and, or, xor, not), v.buffer (buff_point, buff_line, buff_area) and v.patch (patch) as algebraic expression for vector map operations. The implementation will be realised with PLY (http://www.dabeaz.com/ply/) and PyGRASS and will work as a standalone module. In the next step we will develop the temporal algebra that provides temporal variables (day of year, weekday, datum, time, ...) and spatio-temporal topology relations (predecessor, successor, follows, equals, in, meet, …) to perform analyses based on dataset spatio-temporal topologies. The TGRASS GIS API delivers the required functionalities to set up the spatio-temporal relationships for raster and vector datasets. This is the base to create GRASS modules for spatio-temporal vector and raster map calculations:<br />
<br />
'''t.vect.mapcalc'''<br />
<br />
The spatio-temporal vector map calculation module will be derived by combining the new implemented module v.mapcalc with the spatio-temporal algebra into a new module named t.vect.mapcalc. This module will provide all vector calculation options from v.mapcalc with additional spatio-temporal algebra. The implementation of a class structure will ensure that the new class is based on the classes for vector and spatio-temporal algebra and inherits all their functionalities.<br />
<br />
'''t.rast.mapcalc'''<br />
<br />
The spatio-temporal raster map calculation module will be derived by combining the existing module r.mapcalc with the new implemented spatio-temporal algebra. In result the arithmetic operation from r.mapcalc will be extended by spatio-temporal algebra. This module will be based on the same class for spatio-temporal algebra as t.vect.mapcalc to avoid redundancy. <br />
<br />
= Project plan =<br />
<br />
<br />
{| {{table}}<br />
|-<br />
!Period !! Task !! Status / Notes<br />
|-<br />
|May 31 || Getting familiar with PLY and PyGRASS, read documentations || {{done}}<br />
|-<br />
|June 7 || Implement v.mapcalc || {{done}}<br />
|-<br />
|June 14 || Working with TGIS API framework || {{done}}<br />
|-<br />
|June 21 || Create temporal algebra draft, writing example programs || {{done}}<br />
|-<br />
|June 28 || Creating spatio-temporal algebra by using TGIS API ||<br />
|-<br />
|July 5 || Implementation of temporal algebra in PLY || <br />
|-<br />
|July 12 || Continue testing and implementation of temporal algebra || <br />
|-<br />
|July 19 || Writing documentation for temporal algebra || <br />
|-<br />
|July 26 || Implementation of t.vect.mapcalc with documentation and tests || <br />
|-<br />
|'''August 2''' || Mid-term evaluations deadline || <br />
|-<br />
|August 9 || Write documentation and tests for t.vect.mapcalc|| <br />
|-<br />
|August 16 || Implementation of t.rast.mapcalc || <br />
|-<br />
|August 23 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|August 30 || Continue implementation of t.rast.mapcalc || <br />
|-<br />
|September 6 || Write documentation and tests for t.rast.mapcalc || <br />
|-<br />
|'''September 16''' || Suggested 'pencils down' date || <br />
|-<br />
|September 20 || Write tutorials for t.vect/t.rast.mapcalc || <br />
|-<br />
|'''September 27''' || Final evaluation<br />
|}<br />
<br />
= Weekly Reports =<br />
<br />
== Week 1 - 2012-05-31 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Studying [http://www.dabeaz.com/ply/ Python-Lex-Yacc] parsing tool.<br />
* Getting familiar with PyGRASS.<br />
* Working with the [https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form Backus Naur form] of context free grammar.<br />
* Create example programs for the vector algebra in PLY.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Implement the vector algebra GRASS module '''v.mapcalc''' with PLY and PyGRASS.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
<br />
First I was a little bit confused about how PLY works. It took a while until I understood the principals and the functioning.<br />
<br />
== Week 2 - 2012-06-7 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Develop a first implementation of vector algebra in PLY.<br />
* Create a new website on [https://code.google.com/p/grass-gis-temporal-algebra/ | google code].<br />
* Upload v.mapcalc module into the new repository.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Getting familiar with the GRASS GIS Temporal Framework API.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
Some problems with the vector algebra lexer class for boolean operations.<br />
<br />
== Week 3 - 2012-06-14 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Fixed bugs and worked on comments for the v.mapcalc module.<br />
* Reading the documentation for the [http://grass.osgeo.org/programming7/pythontemporallib.html GRASS GIS Temporal Framework API].<br />
* Building up a concept for the temporal algebra together with my mentor.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Write example programs for the temporal algebra<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
The concept get considerably large and it was hard to design it clearly arranged and intuitive.<br />
<br />
== Week 4 - 2012-06-21 ==<br />
<br />
=== What did I do this week? ===<br />
<br />
* Extended the v.mapcalc module with a command list class (Important for later use in preprocessing steps of the temporal algebra).<br />
* Create a developer wiki page for the temporal algebra [http://trac.osgeo.org/grass/wiki/Grass7/TemporalGISAlgebra concept].<br />
* Working on the concept.<br />
* Writing first example programs, experience with the TGIS framework.<br />
<br />
=== What will I be working on next week? ===<br />
<br />
Start implementing the temporal algebra.<br />
<br />
=== Did I meet with any stumbling blocks? ===<br />
No major problem this week.</div>Masthohttps://grasswiki.osgeo.org/w/index.php?title=GRASS_Community_Sprint_Prague_2013&diff=18798GRASS Community Sprint Prague 20132013-05-31T11:32:45Z<p>Mastho: /* In person */</p>
<hr />
<div>{{toc|right}}<br />
The GRASS GIS [[team]] will organize the '''4th GRASS Developer and Power User Meeting, aka 'GRASS GIS Community Sprint'''' from '''July 12 to July 18, 2013'''. The sprint is following the [http://geoinformatics.fsv.cvut.cz/gwiki/Geoinformatics_FCE_CTU_2013 Geoinformatics conference], 11-12 July 2013, Czech Technical University in {{wikipedia|Prague}}, {{wikipedia|Czech Republic}}.<br />
<!--<br />
[[Image:community_sprint_prague2012.png|center|640px]]<br />
<br />
<center><br />
Our logo &mdash; Let's call the dog [http://books.google.com/books?id=sfQuAAAAIAAJ Dashenka]<br />
<br />
'''[http://grass.osgeo.org/announces/community_sprint_prague2012.html Press release]'''<br />
</center><br />
--><br />
<br />
'''Important dates:'''<br />
<br />
* <font color="grey">11 (Thusday) - 12 (Friday) July 2013: [http://geoinformatics.fsv.cvut.cz/gwiki/Geoinformatics_FCE_CTU_2013 Geoinformatics conference]</font><br />
<br />
* '''12 (Friday) - 18 (Thusday) July 2013: GRASS GIS Community Sprint''' @ [http://www.fsv.cvut.cz/ FCE CTU]<br />
<br />
== Purpose ==<br />
<br />
This fourth edition of the GRASS GIS Community Sprint 2013 is a great occasion for folks to support the development by actively contributing to the source code, manuals or likewise. The '''community''' sprint is a get-together for GRASS project members and supporters and related [http://www.osgeo.org OSGeo] projects to make decisions and tackle larger problems. For this meeting, we welcome people committed to improving the GRASS GIS project and the interfaces to [[QGIS GRASS Cookbook|QGIS]], [[GDAL]], [[PostGIS]], [[R statistics]], [[GRASS and Sextante|Sextante, gvSIG]], OGC Services (esp. [[WPS]]) and more. This includes developers, documenters, bug reporters, translators and others.<br />
<br />
For this meeting, we welcome people committed to improving the GRASS GIS and related projects. This includes developers, document writers, wish and bug reporters, translators etc.<br />
<br />
== Sponsors ==<br />
<br />
We welcome '''financial contributions''' to support the meeting and we are looking for sponsors to cover costs such as meals or to help reducing travelling and accommodation expenses for GRASS developers with far arrival If you are interested to sponsor the GRASS Community Sprint, please read about<br />
<br />
:::'''sponsoring the GRASS project at [http://grass.osgeo.org/donations http://grass.osgeo.org/donations]'''<br />
<br />
For questions, please contact [[User:Neteler|Markus Neteler]] <tt><neteler at osgeo.org></tt>. Any surplus at the end of the event will be turned over to the GRASS GIS project.<br />
<br />
This fourth GRASS Community Sprint is a great occasion for you to support the development of GRASS. With your contribution you'll enable more developers to meet. The community sprint is an important opportunity for the GRASS developers to discuss and collaboratively resolve bugs, plan the direction for the project and work on new features. Please see below for the more detailed agenda. The developers and contributors are donating their valuable time, so it would be great if in-kind funding can be made available from within the community to cover out-of-pocket expenses. All of the work that takes place at the community sprint will be directly contributed back into the GRASS project to the benefit of everyone who uses it.<br />
<br />
=== Thanks to our sponsors ===<br />
<br />
We are grateful for the support which we have received to organize this GRASS Community Sprint:<br />
<!--<br />
* remainder from the 2012 edition of the Community Sprint and small donations (via [http://www.gfoss.it/ GFOSS.it], the Italian OSGeo chapter) - 1400 Euro <br />
* [http://www.osgeo.org/ Open Source Geospatial Foundation] (OSGeo) - 1000 Euro<br />
--><br />
<br />
== Timing ==<br />
<br />
'''When''': 12-18 July, 2013<br />
<br />
Of course you are invited to join or leave the community sprint whenever you want.<br />
<br />
'''Duration''': tbd<br />
<br />
* Friday (12. July) is day of arrival<br />
** First meeting in the afternoon (after the [http://geoinformatics.fsv.cvut.cz/gwiki/Geoinformatics_FCE_CTU_2013 Geoinformatics conference]) to define the agenda<br />
* Saturday to Wednesday<br />
** Full days<br />
* Thursday (18. July) is day of departure<br />
** Probably hacking for people with a flight later in the evening<br />
<br />
== Venue ==<br />
[[Image:logo_cvut.jpg|130px|left]]<br />
Department of Mapping and Cartography<br><br />
[http://www.fsv.cvut.cz Faculty of Civil Engineering]<br><br />
[http://www.cvut.cz Czech Technical University in Prague], {{wikipedia|Czech Republic}}<br><br />
[http://geoinformatics.fsv.cvut.cz/gwiki/Room_B367 Room B367] <br><br />
<br />
'''[http://geoinformatics.fsv.cvut.cz/gwiki/Where_you_can_find_us Location & Transportations]'''<br />
<br />
Prague has an international [http://www.prg.aero/en/ airport] and is also reachable by train, bus or car.<br />
<br />
== Accommodation and Costs ==<br />
<br />
Participants should plan for the following costs:<br />
<br />
* The participation is free of charge<br />
* Travel to Prague, variable depending on where you come from<br />
* Accommodation and meals (with the donated sponsorship money we will try to cover some expenses of the participants)<br />
'''Please note''': The currency in Czech Republic is {{wikipedia|Czech crown}} (CZK, koruna, Kč). 100 Czech crowns are about 4 Euros (see [http://www.cnb.cz/en/financial_markets/foreign_exchange_market/exchange_rate_fixing/daily.jsp current rates]).<br />
<br />
'''[http://geoinformatics.fsv.cvut.cz/gwiki/Accommodation_in_Prague Accommodation in Prague]'''<br />
<br />
:* [http://geoinformatics.fsv.cvut.cz/gwiki/Accommodation_in_Prague#Masarykova_Kolej_Hotel Masarykova Kolej Hotel]<br />
:* [http://geoinformatics.fsv.cvut.cz/gwiki/Accommodation_in_Prague#Hotel_DAP Hotel DAP]<br />
:* [http://geoinformatics.fsv.cvut.cz/gwiki/Accommodation_in_Prague#Hotel_Krystal Hotel Krystal]<br />
:* [http://geoinformatics.fsv.cvut.cz/gwiki/Accommodation_in_Prague#Pension_Hanspaulka Pension Hanspaulka]<br />
:* [http://geoinformatics.fsv.cvut.cz/gwiki/Accommodation_in_Prague#Hotel_Silenzio Hotel Silenzio]<br />
:* [http://geoinformatics.fsv.cvut.cz/gwiki/Accommodation_in_Prague#Student_hostels_.28CTU.29 Student hostels (CTU)]<br />
:* Special offer: ''sleeping for free in the kindergarten'' (30min by city urban mass transportation from the university campus, sleeping bag required, kitchen and WC available, no showers, in working days available only from 8 p.m. to 8 a.m.), contact [[User:Landa|Martin Landa]] for details<br />
:* See also http://www.hotel.cz/praha-6/accommodation/<br />
<br />
Please let us know your time of arrival and leaving, so we can book for the accommodations and organize the logistics.<br />
<br />
Financial support: (partial) travel grants can be payed upon request thanks to our sponsors!<br />
<br />
== Weather and Common Item Prices ==<br />
<br />
* In July the weather in Prague is usually warm ([http://www.prague-spot.com/climate 20 or more degrees by day])<br />
* A espresso coffee is about 25 CZK (1 euro), a beer (half of liter) in a common pub is around 30 CZK (1 euro 20 cents), can be more in special pubs. In Prague you can have a full meal (see {{wikipedia|Czech cuisine}} for details) for 100 - 150 CZK (4 - 6 euros), but beware of tourist restaurants, the price can easily rise. It's quite easy to find in Prague also Italian or Chinese restaurants.<br />
<br />
== Agenda - What we plan to do ==<br />
<br />
'''Note:''' The program is generally open for your ideas. Please write an email to the [http://lists.osgeo.org/mailman/listinfo/grass-dev GRASS developer list] to discuss your contribution.<br />
<br />
Further details about the action items you '''find [[Talk:GRASS Community Sprint Prague 2013|here]]''' and below. Topics cover non-technical, semi-technical, and technical issues.<br />
<br />
=== Timeline ===<br />
<br />
==== Friday, 12 July ====<br />
* ''(time to be defined)'': Kick-off in the Faculty of Civil Engineering, building B, room 367 (3rd floor, [http://geoinformatics.fsv.cvut.cz/gwiki/Where_you_can_find_us map])<br />
* Participants presentation<br />
<!--<br />
* 20:00: Dinner at restaurant [http://www.budvarkadejvice.cz Budvarka] near the university, see the [http://www.openstreetmap.org/?mlat=50.09824&mlon=14.3962&zoom=15&layers=M map]<br />
--><br />
<br />
==== Saturday, 13 July ====<br />
<br />
* 9:00-evening<br />
<!--* 20:00: Dinner at restaurant [http://www.restaurant-uglaubicu.cz/ U Glaubiců] in the city center, see the [http://www.openstreetmap.org/?mlat=50.0876&mlon=14.4035&zoom=16&layers=M map]--><br />
<br />
==== Sunday, 14 July ====<br />
<br />
* 9:00-evening<br />
<!--* 20:00: Dinner at restaurant [http://www.hlucna-samota.cz/ Hlučná samota], see the [http://www.openstreetmap.org/?mlat=50.071600&mlon=14.436300&zoom=18&layers=M map]--><br />
<br />
==== Monday, 15 July ====<br />
<br />
* 9:00-evening<br />
<!--* 20:00: Dinner at restaurant [http://www.restauraceztratynalezy.estranky.cz/ Ztráty a nálezy], see the [http://www.openstreetmap.org/?mlat=50.07836&mlon=14.43524&zoom=16&layers=M map]--><br />
<br />
==== Tuesday, 16 July ====<br />
<br />
* 9:00-evening<br />
<!--* 19:00: Dinner at restaurant [http://www.uveverky.com U Veverky], see the [http://www.openstreetmap.org/?mlat=50.09909&mlon=14.4022&zoom=16&layers=M map]--><br />
<br />
==== Wednesday, 17 July ====<br />
<br />
* 9:00-evening<br />
* '''30 YEARS OF GRASS GIS''' party!!<br />
<br />
==== Thursday, 18 July ====<br />
<br />
* Last meeting<br />
* Farewell and have a good trip home<br />
<br />
== Participation ==<br />
<br />
We are planning for an attendance of 20 people (i.e., coding places) but of course you are welcome to join us and bring new ideas with you: we'll make more places available. Please add your name here or contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt>:<br />
<br />
=== In person ===<br />
<br />
{|class="wikitable sortable" border="2" cellspacing="0" cellpadding="4" rules="all" style="margin:1em 1em 1em 0; border:solid 1px #AAAAAA; border-collapse:collapse; background-color:#edf9c7; font-size:95%; empty-cells:show;" <br />
!width=50px|'''Number'''<br />
!width=130px|'''Participant '''<br />
!width=100px|'''Country'''<br />
!width=100px|'''Arrival'''<br />
!width=100px|'''Departure'''<br />
!'''Topic'''<br />
!width=75px|'''T-Shirt'''<br />
!'''Notes'''<br />
|-<br />
|1<br />
|[[User:Landa|Martin Landa]]<br />
|Czech Republic<br />
| July 12<br />
| July 18<br />
| Toolbox concept, vector engine in GRASS 7, wxGUI, PostGIS Topology support, 3D topology<br />
| L<br />
|<br />
|-<br />
|2<br />
| [[User:Neteler|Markus Neteler]]<br />
| Italy<br />
| July 12<br />
| July 18<br />
| Varia<br />
| M<br />
| <br />
|-<br />
|3<br />
| [[User:Helena|Helena Mitasova]]<br />
| USA<br />
| July 16 pm<br />
| July 18<br />
| Data exchange, metadata, GRASS7 data sets, temporal data<br />
| M<br />
| <br />
|-<br />
|4<br />
| [[User:benducke|Benjamin Ducke]]<br />
| Germany<br />
| July 15 (+/- 1)<br />
| July 18 (+/- 1)<br />
| 3D interpolation in GRASS 7 (GSoC), misc.<br />
| M<br />
|<br />
|-<br />
|5<br />
| [[User:ychemin|Yann Chemin]]<br />
| France<br />
| July 11 (+/- 1)<br />
| July 16 (pm)<br />
| image processing, planetary integration<br />
| XXL<br />
|<br />
|-<br />
|6<br />
| [[User:huhabla|Sören Gebbert]]<br />
| Germany<br />
| July 12<br />
| July 16 (pm)<br />
| GRASS GIS Temporal Framework, Temporal GIS Algebra, WPS, visualization and animation of spatio-temporal data<br />
| XL<br />
|<br />
|-<br />
|7<br />
| [[User:annakrat|Anna Petrasova]]<br />
| Czech Republic<br />
| July 11<br />
| July 18<br />
| wxGUI (toolboxes, refactoring, wxNviz, animations)<br />
| M<br />
|<br />
|-<br />
|8<br />
| [[User:wenzeslaus|Vaclav Petras]]<br />
| Czech Republic<br />
| July 11<br />
| July 18<br />
| wxGUI (toolboxes, refactoring), Programmer's manual Doxygen issues<br />
| S<br />
|<br />
|-<br />
|9<br />
| [[User:turek|Štěpán Turek]]<br />
| Czech Republic<br />
| July 11<br />
| July 18<br />
| Scatter Plot, Bundle Adjustment<br />
| L<br />
|<br />
|-<br />
|10<br />
| [[User:mmetz|Markus Metz]]<br />
| Italy<br />
| July 12<br />
| July 18<br />
| vector engine in GRASS 7, image processing, orthorectification<br />
| L<br />
|<br />
|-<br />
|11<br />
| [[User:mastho|Thomas Leppelt]]<br />
| Germany<br />
| July 12<br />
| July 16<br />
| Temporal GIS Algebra<br />
| M<br />
| <br />
|-<br />
|12<br />
| ''and you ...''<br />
| <br />
| <br />
| <br />
| <br />
| <br />
| <br />
|-<br />
|}<br />
<br />
=== Via IRC chat or hangout===<br />
<br />
: [irc://freenode/grass #grass] on Freenode<br />
: [http://www.google.com/+/learnmore/hangouts/ G+ hangout]<br />
:: (to be investigated; smartphones only? (''not sure, but I don't think so'')<br />
:: do you have to be signed up with a Google+ social media account?<br />
:: is Jitsi on a desktop computer compatible? --''not sure, but Jisti offers its own work-alike free multi-person video chat for XMPP(Jabber compatibles) which is not limited to 10 people: [https://jitsi.org/Projects/JitsiVideobridge VideoBridge]'')<br />
<br />
For details, see [[IRC]]<br />
<br />
Please add yourself here below (please add also your gmail account for G+ hangout):<br />
<br />
* [[User:Landa|Martin Landa]], [http://www.timeanddate.com/worldclock/city.html?n=204 timezone]. Gmail is <landa.martin@> expanded <br />
* ...<br />
<br />
'''Timing of hangout meetings:'''<br />
<br />
* Date, time: [http://doodle.com/f2qfqixqeqkkmskh doodle-poll]<br />
<br />
=== Collaborative document scratching ===<br />
<br />
(Power) users from all over the world are kindly invited to assist with testing of new and existing functionality. To collect results and notes, we set up an interactive, collaborative editing tool which works in real-time:<br />
<br />
Please check http://titanpad.com/I51nq1SrNc<br />
<br />
== Individual Preparation ==<br />
<br />
* Bring your own computer<br />
* Bring {{wikipedia|AC adapter|power connector adapter}} if needed (Czech Republic: 230V, 50Hz, {{wikipedia|File:Euro-Flachstecker_2.jpg|Type C Europlugs}} are common and also {{wikipedia|File:French_plug_and_socket.jpg|Type E}})<br />
* Install subversion and the compiler tools, and come with a working GRASS development environment if possible.<br />
<br />
== Broadcast & Video ==<br />
<br />
During the event :)<br />
<br />
== Photos ==<br />
<br />
Also during the event :)<br />
<br />
== FAQ ==<br />
<br />
* '''How was it last time?'''<br />
** Very nice, see [[GRASS Community Sprint Genova 2013]]!<br />
* ''Is the GRASS Community Sprint just a coding event?''<br />
** It is mainly a coding and documentation event. It is a working session for people who are already participants in the GRASS project and/or are committed to improving the GRASS project.<br />
** On demand we can do some presentations of current working GRASS implementation and new upcoming features to spread the idea of Open Source GIS software<br />
* ''Is the GRASS Community Sprint for developers only?''<br />
** No: anybody can help, with testing, checking out bugs and fixes, documentation and more.<br />
* ''Where can I get help and more information about the community sprint?''<br />
** Contact [[User:Landa|Martin Landa]] <tt><landa.martin at gmail.com></tt><br />
<br />
== Press Release ==<br />
<br />
''(to be done)''<br />
<!--http://grass.osgeo.org/announces/community_sprint_prague2012.html--><br />
<br />
[[Category: Workshops]]</div>Mastho