Creating animation from FUTURES output in GRASS GIS: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
(extent text in the first part, move images to right (they are small))
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This is a tutorial how to create an animation from the output of {{AddonCmd|r.futures.pga}} addon module which is a part of {{AddonCmd|r.futures}}, an implementation of FUTURES model. It uses GRASS temporal framework to get the output time series into a spatio-temporal dataset which is then used as an input for the [[WxGUI Animation Tool]] ({{Cmd|g.gui.animation}}. Not all steps from the tutorial might apply to you case depending on how your input data are structured, which color tables you are using and what static data you wish to add to the animation.
This is a tutorial how to create an animation from the output of {{AddonCmd|r.futures.pga}} addon module which is a part of {{AddonCmd|r.futures}}, an implementation of FUTURES model. It uses {{cmd|temporalintro|desc=GRASS temporal framework}} to get the output time series into a spatio-temporal dataset which is then used as an input for the [[WxGUI Animation Tool]] ({{Cmd|g.gui.animation}}. Not all steps from the tutorial might apply to you case depending on how your input data are structured, which color tables you are using and what static data you wish to add to the animation.


== Setting a color of the initial development raster to match the outputs ==
== Brief intro to GRASS GIS temporal framework ==
When using temporal framework, we do not work with individual map layers but with space-time
datasets. Dataset is a collection of individual map layers with assigned time stamps.
Note that raster, vector and 3D raster data is still stored in standard GRASS database, and temporal framework manages the
temporal metadata in separate temporal database.


First, convert the initial development into same classes as output from {{AddonCmd|r.futures.pga}} (1 for developed, NULL (NoData) for everything else. For this task we can use raster algebra, for example:
Dataset can have ''absolute'' (2016-01-01) or ''relative'' (5 years) temporal type. Maps in dataset can use ''intervals'' (both start and end) or instances (only start).


<pre>r.mapcalc &quot;development_initial = if(lc96 == 0, 1, null())&quot;</pre>


[[Image:futures_anim_start_raster_color.png|frame|right|Finding manage color rules (color tables) in main menu]]
Additional material:
* [http://fatra.cnr.ncsu.edu/temporal-grass-workshop/TGRASS_intro.pdf short presentation] from FOSS4G 2014 workshop
* [http://www.slideshare.net/Luis_de_Sousa/presentation-soeren GRASS as a Temporal GIS - Sören Gebbert] (longer presentation)
* {{cmd|temporalintro|desc=official documentation}}
* [[Temporal_data_processing|examples and workflows]]


Now, let's set the color table using interactive raster color management tool (a wrapper around {{Cmd|r.colors}} module). The tool is in ''Raster > Manage colors > Manage color rules interactively''.
== Creating spatio-temporal dataset from the output ==
 
[[Image:futures_anim_raster_set_color.png|frame|right|Setting a color for a raster category using an interactive dialog]]
 
The tools lists individual categories and we can set the desired colors. If desired, we use the pipette tool to get the color from areas in an existing raster already shown in the ''Map Display''.
 
[[Image:futures_anim_make_copy.png|frame|right|A copy of a map from different Mapset can be created using context button of a layer in the Layer Manager]]
 
Other raster maps which we can show afterwards together with the animation, might need some polishing of color table. In some cases it advantageous to copy the raster map into a current mapset using right click on the raster layer in ''Layer Manager'' and select ''Make copy in the current mapset'' in the context menu.


== Creating spatio-temporal dataset from the output ==
The ''Animation tool'' can work directly with the rasters, however it is more advantageous to register all the rasters in the time series into the temporal database.


The ''Animation tool'' can work directly with the rasters, however it is more advantageous to register all the rasters in the time series into the temporal database. Start by creating a spatio-temporal raster dataset:
Start by creating a spatio-temporal raster dataset with ''relative'' temporal type:


<pre>t.create output=futures_development type=strds temporaltype=absolute \
<pre>t.create output=futures_series type=strds temporaltype=relative \
     semantictype=mean title=&quot;Development&quot; \
     semantictype=mean title=&quot;Development&quot; \
     description=&quot;Development time series generated by FUTURES&quot;</pre>
     description=&quot;Development time series 2012 to 2035 generated by FUTURES&quot;</pre>


Note that backslashes mean that the line continues on the next line. This syntax works in unix-like command lines. In the GUI ''Command Console'', just put everything on one line without any backslashes.
Note that backslashes mean that the line continues on the next line. This syntax works in unix-like command lines. In the GUI ''Command Console'', just put everything on one line without any backslashes.


Now, get list of all map layers in time series generated by {{AddonCmd|r.futures.pga}} (assuming we set <code>output_series=futures_development</code> when we were running the module):
Now, get list of all map layers in time series generated by {{AddonCmd|r.futures.pga}} (assuming we set <code>output_series=final</code> when we were running the module):


[[Image:futures_anim_list_maps.png|frame|right|Copying list of rasters from g.list to t.register GUI dialog]]
[[Image:futures_anim_list_maps.png|frame|right|Copying list of rasters from g.list to t.register GUI dialog]]


<pre>g.list type=raster pattern=futures_development_*</pre>
<pre>g.list type=raster pattern=step_*</pre>


This will create a list of raster maps; each name at one line. Add the initial development at the beginning to complete the list:
This will create a list of raster maps; each name at one line:


<pre>development_initial
<pre>
futures_development_00
step_00
futures_development_01
step_01
...
...
futures_development_33
step_22
futures_development_34
step_23
futures_development_35</pre>
</pre>


You can prepare the list of rasters in a (plain) text editor and use the file as an input for {{Cmd|t.register}}. Alternatively, you can use GUI dialog for {{Cmd|t.register}} and copy and paste the list of rasters from {{Cmd|g.list}} directly into the given input box of the <code>file</code> option. In any case, the command should be similar to this one:
You can prepare the list of rasters in a (plain) text editor and use the file as an input for {{Cmd|t.register}}. Alternatively, you can use GUI dialog for {{Cmd|t.register}} and copy and paste the list of rasters from {{Cmd|g.list}} directly into the given input box of the <code>file</code> option. In any case, the command should be similar to this one:


<pre>t.register input=futures_development@futures_test \
<pre>t.register input=futures_series \
     file=.../.tmp/fatra/5311.19 start=1996 unit=years increment=1</pre>
     file=.../.tmp/fatra/5311.19 start=2012 unit=years increment=1</pre>
 
To verify we registered dataset correctly, we can check {{Cmd|t.info}} and {{Cmd|t.rast.list}} output:
<pre>
t.info futures_series
t.rast.list futures_series
</pre>


== Animation tool ==
== Animation tool ==
Start GRASS GIS Animation tool from main menu ''File &gt; Animation Tool'' (or from command line {{Cmd|g.gui.animation}}). Then find ''Add new animation'' button in the toolbar and press it.
Animation tool can display a series of raster or vector maps or spatio-temporal datasets. Similarly to the ''Map Display'' the animation tool can display different static layers, raster or vector.  We have already registered the output from {{AddonCmd|r.futures.pga}} as a spatio-temporal dataset, so we can simply use just this dataset. Set ''Input data type'' to ''Space-time raster dataset'' and then select the dataset we created earlier.


Start GRASS GIS Animation tool from main menu ''File &gt; Animation Tool'' (or from command line {{Cmd|g.gui.animation}}).
To make the animation more informative, we can display also different static layers (which won't change during the animation), for example roads, or shaded relief.
By double-clicking on the layer we can change its display properties, for example for vector we can change symbology in {{cmd|d.vect}} dialog. Also, we can make the layers semi-transparent if needed.


[[Image:futures_anim_start_animation_tool.png|frame|right|Animation tool in the main menu]]
Animation tool displays the extent of computational region. To change the extent, change the computational region, for example from ''Map display'' - ''Various zoom options'' - ''Set computational region extent interactively'' and draw the extent. Press ''Rerender'' in Animation tool.


[[Image:futures_anim_animation_layers.png|frame|right|Managing layers of an animation]]
<center>
{|
|-
| [[Image:futures_anim_start_animation_tool.png|frame|thumb|Animation tool in the main menu]]
| [[Image:futures_anim_animation_time_series.png|frame|thumb|Adding space time raster dataset as a layer which will be animated]]
| [[Image:futures_anim_animation_layers.png|frame|thumb|Managing layers of an animation]]  
| [[Image:futures_anim_vector_set_color.png|frame|thumb|Vector layer properties and symbology dialog (d.vect module dialog)]]
| [[Image:futures_anim_render_animation.png|frame|thumb|Animation can be re-rendered after resizing window using a button in toolbar]]
|-
|}
</center>


[[Image:futures_anim_animation_time_series.png|frame|right|Adding space time raster dataset as a layer which will be animated]]
Suggested layers include (from bottom to top) semi-transparent landuse map <tt>landuse_2011</tt>, FUTURES time series <tt>futures_series</tt>, initial binary development layer <tt>urban_2011</tt> (with <tt>d.rast values=1</tt> for displaying only developed areas) and <tt>roads</tt>.
Use tool in ''Raster > Manage colors > Manage color rules interactively'' to set color of <tt>urban_2011</tt> to grey.


The colors for vector are typically managed when displaying the layer and this is also the case for roads vector.
<center>
{|
|-
| [[Image:futures_anim_raster_set_color.png|frame|thumb|Setting a color for a raster category using an interactive dialog]]
| [[Image:FUTURES_animation_tool.gif|frame|thumb|FUTURES results animated using GRASS GIS Animation tool]]
|-
|}
</center>


[[Image:futures_anim_vector_set_color.png|frame|right|Vector layer properties and symbology dialog (d.vect module dialog)]]


Unlike other properties the opacity is managed separately in the list of layers.


Rendering animation takes some time and thus the rendering is not triggered automatically when changing the size of the window. As a result, we need to press render button in toolbar when we changed the size of the window.


[[Image:futures_anim_render_animation.png|frame|right|Animation needs to be re-rendered after resizing window using a button in toolbar]]


[[Category: Tutorial]]
[[Category: Tutorial]]
[[Category: FUTURES]]
[[Category: FUTURES]]
[[Category: Urban]]
[[Category: Urban]]

Latest revision as of 03:28, 30 March 2016

This is a tutorial how to create an animation from the output of r.futures.pga addon module which is a part of r.futures, an implementation of FUTURES model. It uses GRASS temporal framework to get the output time series into a spatio-temporal dataset which is then used as an input for the WxGUI Animation Tool (g.gui.animation. Not all steps from the tutorial might apply to you case depending on how your input data are structured, which color tables you are using and what static data you wish to add to the animation.

Brief intro to GRASS GIS temporal framework

When using temporal framework, we do not work with individual map layers but with space-time datasets. Dataset is a collection of individual map layers with assigned time stamps. Note that raster, vector and 3D raster data is still stored in standard GRASS database, and temporal framework manages the temporal metadata in separate temporal database.

Dataset can have absolute (2016-01-01) or relative (5 years) temporal type. Maps in dataset can use intervals (both start and end) or instances (only start).


Additional material:

Creating spatio-temporal dataset from the output

The Animation tool can work directly with the rasters, however it is more advantageous to register all the rasters in the time series into the temporal database.

Start by creating a spatio-temporal raster dataset with relative temporal type:

t.create output=futures_series type=strds temporaltype=relative \
    semantictype=mean title="Development" \
    description="Development time series 2012 to 2035 generated by FUTURES"

Note that backslashes mean that the line continues on the next line. This syntax works in unix-like command lines. In the GUI Command Console, just put everything on one line without any backslashes.

Now, get list of all map layers in time series generated by r.futures.pga (assuming we set output_series=final when we were running the module):

Copying list of rasters from g.list to t.register GUI dialog
g.list type=raster pattern=step_*

This will create a list of raster maps; each name at one line:

step_00
step_01
...
step_22
step_23

You can prepare the list of rasters in a (plain) text editor and use the file as an input for t.register. Alternatively, you can use GUI dialog for t.register and copy and paste the list of rasters from g.list directly into the given input box of the file option. In any case, the command should be similar to this one:

t.register input=futures_series \
    file=.../.tmp/fatra/5311.19 start=2012 unit=years increment=1

To verify we registered dataset correctly, we can check t.info and t.rast.list output:

t.info futures_series
t.rast.list futures_series

Animation tool

Start GRASS GIS Animation tool from main menu File > Animation Tool (or from command line g.gui.animation). Then find Add new animation button in the toolbar and press it.

Animation tool can display a series of raster or vector maps or spatio-temporal datasets. Similarly to the Map Display the animation tool can display different static layers, raster or vector. We have already registered the output from r.futures.pga as a spatio-temporal dataset, so we can simply use just this dataset. Set Input data type to Space-time raster dataset and then select the dataset we created earlier.

To make the animation more informative, we can display also different static layers (which won't change during the animation), for example roads, or shaded relief. By double-clicking on the layer we can change its display properties, for example for vector we can change symbology in d.vect dialog. Also, we can make the layers semi-transparent if needed.

Animation tool displays the extent of computational region. To change the extent, change the computational region, for example from Map display - Various zoom options - Set computational region extent interactively and draw the extent. Press Rerender in Animation tool.

Animation tool in the main menu
Adding space time raster dataset as a layer which will be animated
Managing layers of an animation
Vector layer properties and symbology dialog (d.vect module dialog)
Animation can be re-rendered after resizing window using a button in toolbar

Suggested layers include (from bottom to top) semi-transparent landuse map landuse_2011, FUTURES time series futures_series, initial binary development layer urban_2011 (with d.rast values=1 for displaying only developed areas) and roads. Use tool in Raster > Manage colors > Manage color rules interactively to set color of urban_2011 to grey.

Setting a color for a raster category using an interactive dialog
FUTURES results animated using GRASS GIS Animation tool