<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://grasswiki.osgeo.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=%E2%9A%A0%EF%B8%8FDbvanber</id>
	<title>GRASS-Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://grasswiki.osgeo.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=%E2%9A%A0%EF%B8%8FDbvanber"/>
	<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/wiki/Special:Contributions/%E2%9A%A0%EF%B8%8FDbvanber"/>
	<updated>2026-05-25T07:20:02Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22860</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22860"/>
		<updated>2016-03-22T22:09:43Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Development pressure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch the Graphical User Interface (GUI). The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend). The print screens below depicts how you can add different map layers (left) and display the metadata of your data layers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRASS functionality ==&lt;br /&gt;
One of the advantage of GRASS is the diversity and number of module addons that let you analyze all manner of spatial and temporal. Because it is open source modules are added daily increasing functionality and methods for analysis of your data. GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules] that can be used to prepare and analyze data layers.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Command line vs. GUI interface===&lt;br /&gt;
GRASS modules can be executed either through a GUI or command line interface. The GUI offers a user-friendly approach to executing modules where the user can navigate to data layers that they would like to analyze and modify processing options with simple check boxes. The GUI also offer a easily accessible manual on how to execute a model. The command line interface allows users to execute a module using command prompts specific to that module. This is handy when you are running similar analyses with minor modification or are familiar with the module commands for quick efficient processing. In this workshop we provide module prompts that can be copy and pasted into the command line for our workflow, but you can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computational region===&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
{{cmd|g.region|desc=Computational region}} - is an important raster concept in GRASS that needs some explanation. In GRASS a computational region can be set, subsetting larger extent data for quicker testing of analysis or analysis of specific regions based on adminstrative units. We provide a few points to keep in mind when using the computational region function:&lt;br /&gt;
* defined by region extent and raster resolution&lt;br /&gt;
* applies to all raster operations&lt;br /&gt;
* persists between GRASS session, can be different for different mapsets&lt;br /&gt;
* advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
* run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area that aligns with our base landuse rasters. ''Like explained in the instructions above, you simply need copy and paste these commands into the command prompt of GRASS''.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The FUTURES model uses the locations of development and new development to predict when and where new urban growth will occur. This requires longitudinal data on urban land use. We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data). The NULL area is important in simulating urban growth as it preclude these are from becoming development. For this exercise we assume that water, wetlands and protected areas can not be developed, setting them to NULL.&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
FUTURES is a multi-level modelling framework meaning that we model population projections for subregions and assume that these subregions are influenced differently by the factors that influence where development happens. This requires defining subregions for model implementation. For this exercise we use the county level, which is the finest scale of population data that is available to us. We therefore need to convert vectors of counties to a raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements the POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive possible predictors of urban growth using GRASS modules. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
Slope possibly influences urban growth as steep areas are difficult to build on. We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
Distance to lakes or rivers may contribute to an amenity draw where people would like to build a house in a location where they can view water. First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
Like water protected areas can attract urban growth as people enjoy living near scenic areas. We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
Forest may influence urban growth in different ways. On the one hand it might be costly for developments as tree will need to be removed. On the other hand, people may want to live near forests. We calculate the percentage forest for a 1 km pixel to test forest influence, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Travel time to urban centers can often play a role in development with access to centers where employment is concentrated. Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
Dense road construction often occurs in suburban areas where much much development occurs in U.S. cities. To capture this influence we can calculate road density based on the road network.  We rasterize roads and use a moving window analysis ({{cmd|r.neighbors}}) to compute road density for a 1 km area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
In the U.S. urban development often is clustered around interchanges as this provides easy access on transportation networks. To calculate this influence we will use the TIGER road database of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
Development pressure is an important variable in the FUTURES model that is always include as a dynamic variable reinforcing the pressure of past development. We assume that urban development in one location will increase the chance of development in near proximity. New simulated development is incorporated into calculating this development pressure every time step that FUTURES simulates urban growth. To estimate the influence that this local development pressure has, we include the development pressure {{AddonCmd|r.futures.devpressure}} in our initial model estimates. Development pressure is based on number of neighboring developed cells within a specified search distance, weighted by distance. Its special role in the model allows for path dependent feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22859</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22859"/>
		<updated>2016-03-22T22:01:48Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Distance to interchanges */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch the Graphical User Interface (GUI). The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend). The print screens below depicts how you can add different map layers (left) and display the metadata of your data layers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRASS functionality ==&lt;br /&gt;
One of the advantage of GRASS is the diversity and number of module addons that let you analyze all manner of spatial and temporal. Because it is open source modules are added daily increasing functionality and methods for analysis of your data. GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules] that can be used to prepare and analyze data layers.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Command line vs. GUI interface===&lt;br /&gt;
GRASS modules can be executed either through a GUI or command line interface. The GUI offers a user-friendly approach to executing modules where the user can navigate to data layers that they would like to analyze and modify processing options with simple check boxes. The GUI also offer a easily accessible manual on how to execute a model. The command line interface allows users to execute a module using command prompts specific to that module. This is handy when you are running similar analyses with minor modification or are familiar with the module commands for quick efficient processing. In this workshop we provide module prompts that can be copy and pasted into the command line for our workflow, but you can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computational region===&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
{{cmd|g.region|desc=Computational region}} - is an important raster concept in GRASS that needs some explanation. In GRASS a computational region can be set, subsetting larger extent data for quicker testing of analysis or analysis of specific regions based on adminstrative units. We provide a few points to keep in mind when using the computational region function:&lt;br /&gt;
* defined by region extent and raster resolution&lt;br /&gt;
* applies to all raster operations&lt;br /&gt;
* persists between GRASS session, can be different for different mapsets&lt;br /&gt;
* advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
* run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area that aligns with our base landuse rasters. ''Like explained in the instructions above, you simply need copy and paste these commands into the command prompt of GRASS''.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The FUTURES model uses the locations of development and new development to predict when and where new urban growth will occur. This requires longitudinal data on urban land use. We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data). The NULL area is important in simulating urban growth as it preclude these are from becoming development. For this exercise we assume that water, wetlands and protected areas can not be developed, setting them to NULL.&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
FUTURES is a multi-level modelling framework meaning that we model population projections for subregions and assume that these subregions are influenced differently by the factors that influence where development happens. This requires defining subregions for model implementation. For this exercise we use the county level, which is the finest scale of population data that is available to us. We therefore need to convert vectors of counties to a raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements the POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive possible predictors of urban growth using GRASS modules. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
Slope possibly influences urban growth as steep areas are difficult to build on. We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
Distance to lakes or rivers may contribute to an amenity draw where people would like to build a house in a location where they can view water. First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
Like water protected areas can attract urban growth as people enjoy living near scenic areas. We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
Forest may influence urban growth in different ways. On the one hand it might be costly for developments as tree will need to be removed. On the other hand, people may want to live near forests. We calculate the percentage forest for a 1 km pixel to test forest influence, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Travel time to urban centers can often play a role in development with access to centers where employment is concentrated. Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
Dense road construction often occurs in suburban areas where much much development occurs in U.S. cities. To capture this influence we can calculate road density based on the road network.  We rasterize roads and use a moving window analysis ({{cmd|r.neighbors}}) to compute road density for a 1 km area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
In the U.S. urban development often is clustered around interchanges as this provides easy access on transportation networks. To calculate this influence we will use the TIGER road database of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22858</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22858"/>
		<updated>2016-03-22T21:56:49Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Road density */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch the Graphical User Interface (GUI). The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend). The print screens below depicts how you can add different map layers (left) and display the metadata of your data layers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRASS functionality ==&lt;br /&gt;
One of the advantage of GRASS is the diversity and number of module addons that let you analyze all manner of spatial and temporal. Because it is open source modules are added daily increasing functionality and methods for analysis of your data. GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules] that can be used to prepare and analyze data layers.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Command line vs. GUI interface===&lt;br /&gt;
GRASS modules can be executed either through a GUI or command line interface. The GUI offers a user-friendly approach to executing modules where the user can navigate to data layers that they would like to analyze and modify processing options with simple check boxes. The GUI also offer a easily accessible manual on how to execute a model. The command line interface allows users to execute a module using command prompts specific to that module. This is handy when you are running similar analyses with minor modification or are familiar with the module commands for quick efficient processing. In this workshop we provide module prompts that can be copy and pasted into the command line for our workflow, but you can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computational region===&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
{{cmd|g.region|desc=Computational region}} - is an important raster concept in GRASS that needs some explanation. In GRASS a computational region can be set, subsetting larger extent data for quicker testing of analysis or analysis of specific regions based on adminstrative units. We provide a few points to keep in mind when using the computational region function:&lt;br /&gt;
* defined by region extent and raster resolution&lt;br /&gt;
* applies to all raster operations&lt;br /&gt;
* persists between GRASS session, can be different for different mapsets&lt;br /&gt;
* advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
* run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area that aligns with our base landuse rasters. ''Like explained in the instructions above, you simply need copy and paste these commands into the command prompt of GRASS''.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The FUTURES model uses the locations of development and new development to predict when and where new urban growth will occur. This requires longitudinal data on urban land use. We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data). The NULL area is important in simulating urban growth as it preclude these are from becoming development. For this exercise we assume that water, wetlands and protected areas can not be developed, setting them to NULL.&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
FUTURES is a multi-level modelling framework meaning that we model population projections for subregions and assume that these subregions are influenced differently by the factors that influence where development happens. This requires defining subregions for model implementation. For this exercise we use the county level, which is the finest scale of population data that is available to us. We therefore need to convert vectors of counties to a raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements the POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive possible predictors of urban growth using GRASS modules. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
Slope possibly influences urban growth as steep areas are difficult to build on. We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
Distance to lakes or rivers may contribute to an amenity draw where people would like to build a house in a location where they can view water. First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
Like water protected areas can attract urban growth as people enjoy living near scenic areas. We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
Forest may influence urban growth in different ways. On the one hand it might be costly for developments as tree will need to be removed. On the other hand, people may want to live near forests. We calculate the percentage forest for a 1 km pixel to test forest influence, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Travel time to urban centers can often play a role in development with access to centers where employment is concentrated. Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
Dense road construction often occurs in suburban areas where much much development occurs in U.S. cities. To capture this influence we can calculate road density based on the road network.  We rasterize roads and use a moving window analysis ({{cmd|r.neighbors}}) to compute road density for a 1 km area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22857</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22857"/>
		<updated>2016-03-22T21:52:41Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Travel time to cities */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch the Graphical User Interface (GUI). The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend). The print screens below depicts how you can add different map layers (left) and display the metadata of your data layers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRASS functionality ==&lt;br /&gt;
One of the advantage of GRASS is the diversity and number of module addons that let you analyze all manner of spatial and temporal. Because it is open source modules are added daily increasing functionality and methods for analysis of your data. GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules] that can be used to prepare and analyze data layers.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Command line vs. GUI interface===&lt;br /&gt;
GRASS modules can be executed either through a GUI or command line interface. The GUI offers a user-friendly approach to executing modules where the user can navigate to data layers that they would like to analyze and modify processing options with simple check boxes. The GUI also offer a easily accessible manual on how to execute a model. The command line interface allows users to execute a module using command prompts specific to that module. This is handy when you are running similar analyses with minor modification or are familiar with the module commands for quick efficient processing. In this workshop we provide module prompts that can be copy and pasted into the command line for our workflow, but you can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computational region===&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
{{cmd|g.region|desc=Computational region}} - is an important raster concept in GRASS that needs some explanation. In GRASS a computational region can be set, subsetting larger extent data for quicker testing of analysis or analysis of specific regions based on adminstrative units. We provide a few points to keep in mind when using the computational region function:&lt;br /&gt;
* defined by region extent and raster resolution&lt;br /&gt;
* applies to all raster operations&lt;br /&gt;
* persists between GRASS session, can be different for different mapsets&lt;br /&gt;
* advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
* run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area that aligns with our base landuse rasters. ''Like explained in the instructions above, you simply need copy and paste these commands into the command prompt of GRASS''.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The FUTURES model uses the locations of development and new development to predict when and where new urban growth will occur. This requires longitudinal data on urban land use. We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data). The NULL area is important in simulating urban growth as it preclude these are from becoming development. For this exercise we assume that water, wetlands and protected areas can not be developed, setting them to NULL.&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
FUTURES is a multi-level modelling framework meaning that we model population projections for subregions and assume that these subregions are influenced differently by the factors that influence where development happens. This requires defining subregions for model implementation. For this exercise we use the county level, which is the finest scale of population data that is available to us. We therefore need to convert vectors of counties to a raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements the POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive possible predictors of urban growth using GRASS modules. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
Slope possibly influences urban growth as steep areas are difficult to build on. We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
Distance to lakes or rivers may contribute to an amenity draw where people would like to build a house in a location where they can view water. First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
Like water protected areas can attract urban growth as people enjoy living near scenic areas. We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
Forest may influence urban growth in different ways. On the one hand it might be costly for developments as tree will need to be removed. On the other hand, people may want to live near forests. We calculate the percentage forest for a 1 km pixel to test forest influence, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Travel time to urban centers can often play a role in development with access to centers where employment is concentrated. Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22856</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22856"/>
		<updated>2016-03-22T21:12:18Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Forests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch the Graphical User Interface (GUI). The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend). The print screens below depicts how you can add different map layers (left) and display the metadata of your data layers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRASS functionality ==&lt;br /&gt;
One of the advantage of GRASS is the diversity and number of module addons that let you analyze all manner of spatial and temporal. Because it is open source modules are added daily increasing functionality and methods for analysis of your data. GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules] that can be used to prepare and analyze data layers.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Command line vs. GUI interface===&lt;br /&gt;
GRASS modules can be executed either through a GUI or command line interface. The GUI offers a user-friendly approach to executing modules where the user can navigate to data layers that they would like to analyze and modify processing options with simple check boxes. The GUI also offer a easily accessible manual on how to execute a model. The command line interface allows users to execute a module using command prompts specific to that module. This is handy when you are running similar analyses with minor modification or are familiar with the module commands for quick efficient processing. In this workshop we provide module prompts that can be copy and pasted into the command line for our workflow, but you can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computational region===&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
{{cmd|g.region|desc=Computational region}} - is an important raster concept in GRASS that needs some explanation. In GRASS a computational region can be set, subsetting larger extent data for quicker testing of analysis or analysis of specific regions based on adminstrative units. We provide a few points to keep in mind when using the computational region function:&lt;br /&gt;
* defined by region extent and raster resolution&lt;br /&gt;
* applies to all raster operations&lt;br /&gt;
* persists between GRASS session, can be different for different mapsets&lt;br /&gt;
* advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
* run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area that aligns with our base landuse rasters. ''Like explained in the instructions above, you simply need copy and paste these commands into the command prompt of GRASS''.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The FUTURES model uses the locations of development and new development to predict when and where new urban growth will occur. This requires longitudinal data on urban land use. We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data). The NULL area is important in simulating urban growth as it preclude these are from becoming development. For this exercise we assume that water, wetlands and protected areas can not be developed, setting them to NULL.&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
FUTURES is a multi-level modelling framework meaning that we model population projections for subregions and assume that these subregions are influenced differently by the factors that influence where development happens. This requires defining subregions for model implementation. For this exercise we use the county level, which is the finest scale of population data that is available to us. We therefore need to convert vectors of counties to a raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements the POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive possible predictors of urban growth using GRASS modules. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
Slope possibly influences urban growth as steep areas are difficult to build on. We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
Distance to lakes or rivers may contribute to an amenity draw where people would like to build a house in a location where they can view water. First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
Like water protected areas can attract urban growth as people enjoy living near scenic areas. We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
Forest may influence urban growth in different ways. On the one hand it might be costly for developments as tree will need to be removed. On the other hand, people may want to live near forests. We calculate the percentage forest for a 1 km pixel to test forest influence, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22855</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22855"/>
		<updated>2016-03-22T21:08:35Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Distance from protected areas */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch the Graphical User Interface (GUI). The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend). The print screens below depicts how you can add different map layers (left) and display the metadata of your data layers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRASS functionality ==&lt;br /&gt;
One of the advantage of GRASS is the diversity and number of module addons that let you analyze all manner of spatial and temporal. Because it is open source modules are added daily increasing functionality and methods for analysis of your data. GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules] that can be used to prepare and analyze data layers.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Command line vs. GUI interface===&lt;br /&gt;
GRASS modules can be executed either through a GUI or command line interface. The GUI offers a user-friendly approach to executing modules where the user can navigate to data layers that they would like to analyze and modify processing options with simple check boxes. The GUI also offer a easily accessible manual on how to execute a model. The command line interface allows users to execute a module using command prompts specific to that module. This is handy when you are running similar analyses with minor modification or are familiar with the module commands for quick efficient processing. In this workshop we provide module prompts that can be copy and pasted into the command line for our workflow, but you can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computational region===&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
{{cmd|g.region|desc=Computational region}} - is an important raster concept in GRASS that needs some explanation. In GRASS a computational region can be set, subsetting larger extent data for quicker testing of analysis or analysis of specific regions based on adminstrative units. We provide a few points to keep in mind when using the computational region function:&lt;br /&gt;
* defined by region extent and raster resolution&lt;br /&gt;
* applies to all raster operations&lt;br /&gt;
* persists between GRASS session, can be different for different mapsets&lt;br /&gt;
* advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
* run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area that aligns with our base landuse rasters. ''Like explained in the instructions above, you simply need copy and paste these commands into the command prompt of GRASS''.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The FUTURES model uses the locations of development and new development to predict when and where new urban growth will occur. This requires longitudinal data on urban land use. We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data). The NULL area is important in simulating urban growth as it preclude these are from becoming development. For this exercise we assume that water, wetlands and protected areas can not be developed, setting them to NULL.&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
FUTURES is a multi-level modelling framework meaning that we model population projections for subregions and assume that these subregions are influenced differently by the factors that influence where development happens. This requires defining subregions for model implementation. For this exercise we use the county level, which is the finest scale of population data that is available to us. We therefore need to convert vectors of counties to a raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements the POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive possible predictors of urban growth using GRASS modules. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
Slope possibly influences urban growth as steep areas are difficult to build on. We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
Distance to lakes or rivers may contribute to an amenity draw where people would like to build a house in a location where they can view water. First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
Like water protected areas can attract urban growth as people enjoy living near scenic areas. We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22854</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22854"/>
		<updated>2016-03-22T20:13:49Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Potential submodel */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch the Graphical User Interface (GUI). The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend). The print screens below depicts how you can add different map layers (left) and display the metadata of your data layers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRASS functionality ==&lt;br /&gt;
One of the advantage of GRASS is the diversity and number of module addons that let you analyze all manner of spatial and temporal. Because it is open source modules are added daily increasing functionality and methods for analysis of your data. GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules] that can be used to prepare and analyze data layers.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Command line vs. GUI interface===&lt;br /&gt;
GRASS modules can be executed either through a GUI or command line interface. The GUI offers a user-friendly approach to executing modules where the user can navigate to data layers that they would like to analyze and modify processing options with simple check boxes. The GUI also offer a easily accessible manual on how to execute a model. The command line interface allows users to execute a module using command prompts specific to that module. This is handy when you are running similar analyses with minor modification or are familiar with the module commands for quick efficient processing. In this workshop we provide module prompts that can be copy and pasted into the command line for our workflow, but you can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computational region===&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
{{cmd|g.region|desc=Computational region}} - is an important raster concept in GRASS that needs some explanation. In GRASS a computational region can be set, subsetting larger extent data for quicker testing of analysis or analysis of specific regions based on adminstrative units. We provide a few points to keep in mind when using the computational region function:&lt;br /&gt;
* defined by region extent and raster resolution&lt;br /&gt;
* applies to all raster operations&lt;br /&gt;
* persists between GRASS session, can be different for different mapsets&lt;br /&gt;
* advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
* run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area that aligns with our base landuse rasters. ''Like explained in the instructions above, you simply need copy and paste these commands into the command prompt of GRASS''.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The FUTURES model uses the locations of development and new development to predict when and where new urban growth will occur. This requires longitudinal data on urban land use. We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data). The NULL area is important in simulating urban growth as it preclude these are from becoming development. For this exercise we assume that water, wetlands and protected areas can not be developed, setting them to NULL.&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
FUTURES is a multi-level modelling framework meaning that we model population projections for subregions and assume that these subregions are influenced differently by the factors that influence where development happens. This requires defining subregions for model implementation. For this exercise we use the county level, which is the finest scale of population data that is available to us. We therefore need to convert vectors of counties to a raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements the POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive possible predictors of urban growth using GRASS modules. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
Slope possibly influences urban growth as steep areas are difficult to build on. We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
Distance to lakes or rivers may contribute to an amenity draw where people would like to build a house in a location where they can view water. First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22853</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22853"/>
		<updated>2016-03-22T20:07:31Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Initial steps and data preparation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch the Graphical User Interface (GUI). The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend). The print screens below depicts how you can add different map layers (left) and display the metadata of your data layers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRASS functionality ==&lt;br /&gt;
One of the advantage of GRASS is the diversity and number of module addons that let you analyze all manner of spatial and temporal. Because it is open source modules are added daily increasing functionality and methods for analysis of your data. GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules] that can be used to prepare and analyze data layers.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Command line vs. GUI interface===&lt;br /&gt;
GRASS modules can be executed either through a GUI or command line interface. The GUI offers a user-friendly approach to executing modules where the user can navigate to data layers that they would like to analyze and modify processing options with simple check boxes. The GUI also offer a easily accessible manual on how to execute a model. The command line interface allows users to execute a module using command prompts specific to that module. This is handy when you are running similar analyses with minor modification or are familiar with the module commands for quick efficient processing. In this workshop we provide module prompts that can be copy and pasted into the command line for our workflow, but you can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computational region===&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
{{cmd|g.region|desc=Computational region}} - is an important raster concept in GRASS that needs some explanation. In GRASS a computational region can be set, subsetting larger extent data for quicker testing of analysis or analysis of specific regions based on adminstrative units. We provide a few points to keep in mind when using the computational region function:&lt;br /&gt;
* defined by region extent and raster resolution&lt;br /&gt;
* applies to all raster operations&lt;br /&gt;
* persists between GRASS session, can be different for different mapsets&lt;br /&gt;
* advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
* run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area that aligns with our base landuse rasters. ''Like explained in the instructions above, you simply need copy and paste these commands into the command prompt of GRASS''.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The FUTURES model uses the locations of development and new development to predict when and where new urban growth will occur. This requires longitudinal data on urban land use. We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data). The NULL area is important in simulating urban growth as it preclude these are from becoming development. For this exercise we assume that water, wetlands and protected areas can not be developed, setting them to NULL.&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
FUTURES is a multi-level modelling framework meaning that we model population projections for subregions and assume that these subregions are influenced differently by the factors that influence where development happens. This requires defining subregions for model implementation. For this exercise we use the county level, which is the finest scale of population data that is available to us. We therefore need to convert vectors of counties to a raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22852</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22852"/>
		<updated>2016-03-22T19:57:39Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Initial steps and data preparation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch the Graphical User Interface (GUI). The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend). The print screens below depicts how you can add different map layers (left) and display the metadata of your data layers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRASS functionality ==&lt;br /&gt;
One of the advantage of GRASS is the diversity and number of module addons that let you analyze all manner of spatial and temporal. Because it is open source modules are added daily increasing functionality and methods for analysis of your data. GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules] that can be used to prepare and analyze data layers.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Command line vs. GUI interface===&lt;br /&gt;
GRASS modules can be executed either through a GUI or command line interface. The GUI offers a user-friendly approach to executing modules where the user can navigate to data layers that they would like to analyze and modify processing options with simple check boxes. The GUI also offer a easily accessible manual on how to execute a model. The command line interface allows users to execute a module using command prompts specific to that module. This is handy when you are running similar analyses with minor modification or are familiar with the module commands for quick efficient processing. In this workshop we provide module prompts that can be copy and pasted into the command line for our workflow, but you can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computational region===&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
{{cmd|g.region|desc=Computational region}} - is an important raster concept in GRASS that needs some explanation. In GRASS a computational region can be set, subsetting larger extent data for quicker testing of analysis or analysis of specific regions based on adminstrative units. We provide a few points to keep in mind when using the computational region function:&lt;br /&gt;
* defined by region extent and raster resolution&lt;br /&gt;
* applies to all raster operations&lt;br /&gt;
* persists between GRASS session, can be different for different mapsets&lt;br /&gt;
* advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
* run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area that aligns with our base landuse rasters. ''Like explained in the instructions above, you simply need copy and paste these commands into the command prompt of GRASS''.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The FUTURES model uses the locations of development and new development to predict when and where new urban growth will occur. This requires longitudinal data on urban land use. We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data). The NULL area is important in simulating urban growth as it preclude these are from becoming development. For this exercise we assume that water, wetlands and protected areas can not be developed, setting them to NULL.&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22851</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22851"/>
		<updated>2016-03-22T19:54:48Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Initial steps and data preparation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch the Graphical User Interface (GUI). The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend). The print screens below depicts how you can add different map layers (left) and display the metadata of your data layers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRASS functionality ==&lt;br /&gt;
One of the advantage of GRASS is the diversity and number of module addons that let you analyze all manner of spatial and temporal. Because it is open source modules are added daily increasing functionality and methods for analysis of your data. GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules] that can be used to prepare and analyze data layers.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Command line vs. GUI interface===&lt;br /&gt;
GRASS modules can be executed either through a GUI or command line interface. The GUI offers a user-friendly approach to executing modules where the user can navigate to data layers that they would like to analyze and modify processing options with simple check boxes. The GUI also offer a easily accessible manual on how to execute a model. The command line interface allows users to execute a module using command prompts specific to that module. This is handy when you are running similar analyses with minor modification or are familiar with the module commands for quick efficient processing. In this workshop we provide module prompts that can be copy and pasted into the command line for our workflow, but you can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computational region===&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
{{cmd|g.region|desc=Computational region}} - is an important raster concept in GRASS that needs some explanation. In GRASS a computational region can be set, subsetting larger extent data for quicker testing of analysis or analysis of specific regions based on adminstrative units. We provide a few points to keep in mind when using the computational region function:&lt;br /&gt;
* defined by region extent and raster resolution&lt;br /&gt;
* applies to all raster operations&lt;br /&gt;
* persists between GRASS session, can be different for different mapsets&lt;br /&gt;
* advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
* run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area that aligns with our base landuse rasters. ''Like explained in the instructions above, you simply need copy and paste these commands into the command prompt of GRASS''.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The FUTURES model uses the locations of development and new development to predict when and where new urban growth will occur. This requires longitudinal data on urban land use. We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22850</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22850"/>
		<updated>2016-03-22T19:49:43Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Initial steps and data preparation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch the Graphical User Interface (GUI). The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend). The print screens below depicts how you can add different map layers (left) and display the metadata of your data layers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRASS functionality ==&lt;br /&gt;
One of the advantage of GRASS is the diversity and number of module addons that let you analyze all manner of spatial and temporal. Because it is open source modules are added daily increasing functionality and methods for analysis of your data. GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules] that can be used to prepare and analyze data layers.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Command line vs. GUI interface===&lt;br /&gt;
GRASS modules can be executed either through a GUI or command line interface. The GUI offers a user-friendly approach to executing modules where the user can navigate to data layers that they would like to analyze and modify processing options with simple check boxes. The GUI also offer a easily accessible manual on how to execute a model. The command line interface allows users to execute a module using command prompts specific to that module. This is handy when you are running similar analyses with minor modification or are familiar with the module commands for quick efficient processing. In this workshop we provide module prompts that can be copy and pasted into the command line for our workflow, but you can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computational region===&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
{{cmd|g.region|desc=Computational region}} - is an important raster concept in GRASS that needs some explanation. In GRASS a computational region can be set, subsetting larger extent data for quicker testing of analysis or analysis of specific regions based on adminstrative units. We provide a few points to keep in mind when using the computational region function:&lt;br /&gt;
* defined by region extent and raster resolution&lt;br /&gt;
* applies to all raster operations&lt;br /&gt;
* persists between GRASS session, can be different for different mapsets&lt;br /&gt;
* advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
* run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area that aligns with our base landuse rasters. ''Like explained in the instructions above, you simply need copy and paste these commands into the command prompt of GRASS''.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22849</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22849"/>
		<updated>2016-03-22T19:37:36Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Command line vs. GUI interface */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch the Graphical User Interface (GUI). The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend). The print screens below depicts how you can add different map layers (left) and display the metadata of your data layers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRASS functionality ==&lt;br /&gt;
One of the advantage of GRASS is the diversity and number of module addons that let you analyze all manner of spatial and temporal. Because it is open source modules are added daily increasing functionality and methods for analysis of your data. GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules] that can be used to prepare and analyze data layers.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Command line vs. GUI interface===&lt;br /&gt;
GRASS modules can be executed either through a GUI or command line interface. The GUI offers a user-friendly approach to executing modules where the user can navigate to data layers that they would like to analyze and modify processing options with simple check boxes. The GUI also offer a easily accessible manual on how to execute a model. The command line interface allows users to execute a module using command prompts specific to that module. This is handy when you are running similar analyses with minor modification or are familiar with the module commands for quick efficient processing. In this workshop we provide module prompts that can be copy and pasted into the command line for our workflow, but you can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Computational region===&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
{{cmd|g.region|desc=Computational region}} - is an important raster concept in GRASS that needs some explanation. In GRASS a computational region can be set, subsetting larger extent data for quicker testing of analysis or analysis of specific regions based on adminstrative units. We provide a few points to keep in mind when using the computational region function:&lt;br /&gt;
* defined by region extent and raster resolution&lt;br /&gt;
* applies to all raster operations&lt;br /&gt;
* persists between GRASS session, can be different for different mapsets&lt;br /&gt;
* advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
* run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22848</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22848"/>
		<updated>2016-03-22T19:32:50Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Command line vs. GUI interface */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch the Graphical User Interface (GUI). The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend). The print screens below depicts how you can add different map layers (left) and display the metadata of your data layers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRASS functionality ==&lt;br /&gt;
One of the advantage of GRASS is the diversity and number of module addons that let you analyze all manner of spatial and temporal. Because it is open source modules are added daily increasing functionality and methods for analysis of your data. GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules] that can be used to prepare and analyze data layers.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Command line vs. GUI interface===&lt;br /&gt;
GRASS modules can be executed either through a GUI or command line interface. The GUI offers a user-friendly approach to executing modules where the user can navigate to data layers that they would like to analyze and modify processing options with simple check boxes. The GUI also offer a easily accessible manual on how to execute a model. The command line interface allows users to execute a module using command prompts specific to that module. This is handy when you are running similar analyses with minor modification or are familiar with the module commands for quick efficient processing. In this workshop we provide module prompts that can be copy and pasted into the command line for our workflow, but you can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22847</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22847"/>
		<updated>2016-03-22T19:29:34Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* GRASS functionality */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch the Graphical User Interface (GUI). The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend). The print screens below depicts how you can add different map layers (left) and display the metadata of your data layers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRASS functionality ==&lt;br /&gt;
One of the advantage of GRASS is the diversity and number of module addons that let you analyze all manner of spatial and temporal. Because it is open source modules are added daily increasing functionality and methods for analysis of your data. GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules] that can be used to prepare and analyze data layers.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Command line vs. GUI interface===&lt;br /&gt;
GRASS modules can be executed either through a GUI and command line interface. The GUI offers a user-friendly approach to executing modules where the user can navigate to data layers that they would like to analyze and check processing options. The GUI also offer a easily accessible manual on how to execute a model. The command line interface allows users to execute a module using command prompts specific to that module. This handy when you are running similar analyses with minor modification or are familiar with the module commands for quick efficient processing. In this workshop we provide module prompts that can be copy and pasted into the command line for out workflow, but you can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22846</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22846"/>
		<updated>2016-03-22T19:10:02Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* GRASS functionality */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch the Graphical User Interface (GUI). The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend). The print screens below depicts how you can add different map layers (left) and display the metadata of your data layers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRASS functionality ==&lt;br /&gt;
One of the advantage of GRASS is diverse number of module addons that let you analyze all manner of spatial and temporal. Because it is open source modules are added daily increasing functionality and methods for analysis of your data. GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Command line vs. GUI interface===&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22845</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22845"/>
		<updated>2016-03-22T19:04:29Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Launching and exploring data in GRASS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch the Graphical User Interface (GUI). The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend). The print screens below depicts how you can add different map layers (left) and display the metadata of your data layers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRASS functionality ==&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22844</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22844"/>
		<updated>2016-03-22T19:02:38Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Launching and exploring data in GRASS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch GRASS. The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend). The print screens below depict how you can add different map layer (left) and display the metadata of your data layers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GRASS functionality ==&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22843</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22843"/>
		<updated>2016-03-22T18:59:32Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Creating a GRASS database for the tutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Launching and exploring data in GRASS ===&lt;br /&gt;
Now that we have the data in the correct GRASS database, we can launch GRASS. The GUI interface allows you to display raster, vector data as well as navigate through zooming in and out. Advanced exploration and visualization, like many popular GIS software, is also possible in GRASS (e.g. queries, adding legend).  showing metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22842</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22842"/>
		<updated>2016-03-22T18:52:29Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Creating a GRASS database for the tutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=1 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=2  widths=500 heights=250&amp;gt;Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22841</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22841"/>
		<updated>2016-03-22T18:45:25Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Setting up GRASS for the tutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. In the following we review important terminology and give step by step direction on how to download and place you data in the correct location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22840</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22840"/>
		<updated>2016-03-22T18:43:52Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* GRASS directory system */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== Setting up GRASS for the tutorial ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22839</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22839"/>
		<updated>2016-03-22T18:42:58Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Creating a GRASS database for the tutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== GRASS directory system ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location], noting where the files are located on your local directory. Now, create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should now have a Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22838</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22838"/>
		<updated>2016-03-22T18:40:58Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* GRASS directory system */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== GRASS directory system ==  &lt;br /&gt;
GRASS uses unique database terminology and structure ([https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database]) that are important to understand for the set up of this tutorial, as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
=== Creating a GRASS database for the tutorial ===&lt;br /&gt;
You need to create a GRASS database with the Mapset that we will use for the tutorial before we can run the FUTURES model. Please Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22837</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22837"/>
		<updated>2016-03-22T18:35:43Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* GRASS directory */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== GRASS directory system ==  &lt;br /&gt;
GRASS uses unique database terminology and structure that are important to understand [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database] for the set up of this tutorial as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
To Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22836</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22836"/>
		<updated>2016-03-22T18:34:17Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* GRASS directory */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== GRASS directory ==  &lt;br /&gt;
GRASS uses unique database terminology and structure that are important to understand [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database] for the set up of this tutorial as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location.&lt;br /&gt;
&lt;br /&gt;
=== Important GRASS directory terminology ===&lt;br /&gt;
* A '''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
To Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22835</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22835"/>
		<updated>2016-03-22T18:32:40Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* GRASS directory */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== GRASS directory ==  &lt;br /&gt;
GRASS uses unique database terminology and structure that are important to understand [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database] for the set up of this tutorial as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location.&lt;br /&gt;
&lt;br /&gt;
'''Important GRASS directory terminology'''&lt;br /&gt;
* A'''GRASS database''' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
* '''Location''' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
* '''Mapset''' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
To Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22834</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22834"/>
		<updated>2016-03-22T18:29:59Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* GRASS GIS introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
== GRASS directory ==  &lt;br /&gt;
GRASS uses unique database terminology and structure that are important to understand [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database] for the set up of this tutorial as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. &lt;br /&gt;
** A''GRASS database'' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
** ''Location'' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
** ''Mapset'' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
To Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22833</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22833"/>
		<updated>2016-03-22T18:28:17Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* GRASS GIS introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
* GRASS uses unique database terminology and structure that are important to understand [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database] for the set up of this tutorial as you will need to place the required data (e.g. Mapset) in a specific GRASS database Location. &lt;br /&gt;
** A''GRASS database'' consist of directory with specific Locations (projects) where data layer are stored&lt;br /&gt;
** ''Location'' hold all Mapsets in a specific directoy that have the same spatial projection (spatial reference system)&lt;br /&gt;
** ''Mapset'' are a collection of maps with the same spatial projection&lt;br /&gt;
&lt;br /&gt;
To Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22832</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22832"/>
		<updated>2016-03-22T17:58:41Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* GRASS GIS introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory, as well as some basic GRASS functionality. Step by step instructions are provided below  &lt;br /&gt;
* Our overview of [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database] will include:&lt;br /&gt;
** ''GRASS database'': directory with Locations (projects)&lt;br /&gt;
** ''Location'': directory with Mapsets, defined by projection (spatial reference system)&lt;br /&gt;
** ''Mapset'': collection of maps&lt;br /&gt;
* Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22831</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22831"/>
		<updated>2016-03-22T17:53:36Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Initial steps and data preparation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory and for this we provide step by step instructions.  &lt;br /&gt;
* Overview of [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database].&lt;br /&gt;
** ''GRASS database'': directory with Locations (projects)&lt;br /&gt;
** ''Location'': directory with Mapsets, defined by projection (spatial reference system)&lt;br /&gt;
** ''Mapset'': collection of maps&lt;br /&gt;
* Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area and aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22830</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22830"/>
		<updated>2016-03-22T17:51:12Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Initial steps and data preparation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory and for this we provide step by step instructions.  &lt;br /&gt;
* Overview of [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database].&lt;br /&gt;
** ''GRASS database'': directory with Locations (projects)&lt;br /&gt;
** ''Location'': directory with Mapsets, defined by projection (spatial reference system)&lt;br /&gt;
** ''Mapset'': collection of maps&lt;br /&gt;
* Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set the computational region of our analyses to an extent covering our study area. This also ensures that all data layers (i.e. cells) are aligned with our base landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22829</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22829"/>
		<updated>2016-03-22T17:04:01Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* GRASS GIS introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory and for this we provide step by step instructions.  &lt;br /&gt;
* Overview of [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database].&lt;br /&gt;
** ''GRASS database'': directory with Locations (projects)&lt;br /&gt;
** ''Location'': directory with Mapsets, defined by projection (spatial reference system)&lt;br /&gt;
** ''Mapset'': collection of maps&lt;br /&gt;
* Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set computational region of our analyses to an extent covering our study area and so that the cells are aligned with one of our landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22828</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22828"/>
		<updated>2016-03-22T17:02:48Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* GRASS GIS introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of the GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] that might be helpful to review if you are a first time users. For this exercise it's not necessary to have a full understanding of how to use GRASS. However, you will need to know how to place your data in the correct GRASS database directory.  &lt;br /&gt;
* Overview of [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database].&lt;br /&gt;
** ''GRASS database'': directory with Locations (projects)&lt;br /&gt;
** ''Location'': directory with Mapsets, defined by projection (spatial reference system)&lt;br /&gt;
** ''Mapset'': collection of maps&lt;br /&gt;
* Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set computational region of our analyses to an extent covering our study area and so that the cells are aligned with one of our landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22827</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22827"/>
		<updated>2016-03-22T16:59:41Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* GRASS GIS introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
There are many advantages to using the open source GRASS GIS platform, but for many that are more familiar with ARCGis and QGis, the setup and implementation of spatial tools in GRASS can be confusing. Here we provide an overview of GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org] for first time users. &lt;br /&gt;
* Overview of [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database].&lt;br /&gt;
** ''GRASS database'': directory with Locations (projects)&lt;br /&gt;
** ''Location'': directory with Mapsets, defined by projection (spatial reference system)&lt;br /&gt;
** ''Mapset'': collection of maps&lt;br /&gt;
* Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set computational region of our analyses to an extent covering our study area and so that the cells are aligned with one of our landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22826</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22826"/>
		<updated>2016-03-22T16:55:04Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Software */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
* Overview of GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org]&lt;br /&gt;
* Overview of [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database].&lt;br /&gt;
** ''GRASS database'': directory with Locations (projects)&lt;br /&gt;
** ''Location'': directory with Mapsets, defined by projection (spatial reference system)&lt;br /&gt;
** ''Mapset'': collection of maps&lt;br /&gt;
* Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set computational region of our analyses to an extent covering our study area and so that the cells are aligned with one of our landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22825</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22825"/>
		<updated>2016-03-22T16:54:46Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
* Overview of GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org]&lt;br /&gt;
* Overview of [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database].&lt;br /&gt;
** ''GRASS database'': directory with Locations (projects)&lt;br /&gt;
** ''Location'': directory with Mapsets, defined by projection (spatial reference system)&lt;br /&gt;
** ''Mapset'': collection of maps&lt;br /&gt;
* Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set computational region of our analyses to an extent covering our study area and so that the cells are aligned with one of our landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22824</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22824"/>
		<updated>2016-03-22T16:51:30Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Workshop introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of the '''FUT'''ure '''U'''rban-'''R'''egional '''E'''nvironment '''S'''imulation (FUTURES)&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;sup&amp;gt;[1]&amp;lt;/sup&amp;gt; Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. &lt;br /&gt;
&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
* Overview of GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org]&lt;br /&gt;
* Overview of [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database].&lt;br /&gt;
** ''GRASS database'': directory with Locations (projects)&lt;br /&gt;
** ''Location'': directory with Mapsets, defined by projection (spatial reference system)&lt;br /&gt;
** ''Mapset'': collection of maps&lt;br /&gt;
* Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set computational region of our analyses to an extent covering our study area and so that the cells are aligned with one of our landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22823</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22823"/>
		<updated>2016-03-21T20:11:48Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Workshop data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of FUTure Urban-Regional Environment Simulation (FUTURES)[1] which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
[1] Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. &lt;br /&gt;
&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
* Overview of GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org]&lt;br /&gt;
* Overview of [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database].&lt;br /&gt;
** ''GRASS database'': directory with Locations (projects)&lt;br /&gt;
** ''Location'': directory with Mapsets, defined by projection (spatial reference system)&lt;br /&gt;
** ''Mapset'': collection of maps&lt;br /&gt;
* Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set computational region of our analyses to an extent covering our study area and so that the cells are aligned with one of our landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22822</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22822"/>
		<updated>2016-03-21T20:11:20Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of FUTure Urban-Regional Environment Simulation (FUTURES)[1] which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
[1] Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. &lt;br /&gt;
&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
The data that we will be using for the workshop can be download here: [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset]. Please download and place these layers in your local GRASS directory:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
* Overview of GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org]&lt;br /&gt;
* Overview of [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database].&lt;br /&gt;
** ''GRASS database'': directory with Locations (projects)&lt;br /&gt;
** ''Location'': directory with Mapsets, defined by projection (spatial reference system)&lt;br /&gt;
** ''Mapset'': collection of maps&lt;br /&gt;
* Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set computational region of our analyses to an extent covering our study area and so that the cells are aligned with one of our landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22821</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22821"/>
		<updated>2016-03-21T20:04:23Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of FUTure Urban-Regional Environment Simulation (FUTURES)[1] which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
[1] Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
There are a number of software requirements to run FUTURES that will need to be download and installed. &lt;br /&gt;
&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
Download [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset] containing GRASS GIS location with:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
* Overview of GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org]&lt;br /&gt;
* Overview of [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database].&lt;br /&gt;
** ''GRASS database'': directory with Locations (projects)&lt;br /&gt;
** ''Location'': directory with Mapsets, defined by projection (spatial reference system)&lt;br /&gt;
** ''Mapset'': collection of maps&lt;br /&gt;
* Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set computational region of our analyses to an extent covering our study area and so that the cells are aligned with one of our landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22820</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22820"/>
		<updated>2016-03-21T20:03:24Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of FUTure Urban-Regional Environment Simulation (FUTURES)[1] which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
[1] Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
There are a number of software needed to run FUTURES that will need to be download and installed. &lt;br /&gt;
&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here in the [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
Download [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset] containing GRASS GIS location with:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
* Overview of GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org]&lt;br /&gt;
* Overview of [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database].&lt;br /&gt;
** ''GRASS database'': directory with Locations (projects)&lt;br /&gt;
** ''Location'': directory with Mapsets, defined by projection (spatial reference system)&lt;br /&gt;
** ''Mapset'': collection of maps&lt;br /&gt;
* Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set computational region of our analyses to an extent covering our study area and so that the cells are aligned with one of our landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22819</id>
		<title>Workshop on urban growth modeling with FUTURES</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Workshop_on_urban_growth_modeling_with_FUTURES&amp;diff=22819"/>
		<updated>2016-03-21T20:02:22Z</updated>

		<summary type="html">&lt;p&gt;⚠️Dbvanber: /* Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{ToModify}}&lt;br /&gt;
= Workshop introduction =&lt;br /&gt;
r.futures.* is an implementation of FUTure Urban-Regional Environment Simulation (FUTURES)[1] which is a model for multilevel simulations of emerging urban-rural landscape structure. FUTURES produces regional projections of landscape patterns using coupled submodels that integrate nonstationary drivers of land change: per capita demand (DEMAND submodel), site suitability (POTENTIAL submodel), and the spatial structure of conversion events (PGA submodel).&lt;br /&gt;
&lt;br /&gt;
[1] Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., &amp;amp; Shoemaker, D. A. (2013).  [http://www.tandfonline.com/doi/abs/10.1080/00045608.2012.707591 FUTURES: multilevel simulations of emerging urban-rural landscape structure using a stochastic patch-growing algorithm.] Annals of the Association of American Geographers, 103(4), 785-807&lt;br /&gt;
&lt;br /&gt;
== Software ==&lt;br /&gt;
Required software includes:&lt;br /&gt;
* GRASS GIS 7&lt;br /&gt;
* addons&lt;br /&gt;
** {{AddonCmd|r.futures.pga}}&lt;br /&gt;
** {{AddonCmd|r.futures.potential}}&lt;br /&gt;
** {{AddonCmd|r.futures.potsurface}}&lt;br /&gt;
** {{AddonCmd|r.futures.demand}}&lt;br /&gt;
** {{AddonCmd|r.futures.devpressure}}&lt;br /&gt;
** {{AddonCmd|r.sample.category}}&lt;br /&gt;
* R (≥ 3.0.2) - needed for {{AddonCmd|r.futures.potential}} with packages:&lt;br /&gt;
**MuMIn, lme4, optparse, rgrass7&lt;br /&gt;
* SciPy - useful for {{AddonCmd|r.futures.demand}}&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
There are a number of software needed to run FUTURES that will need to be download and installed. &lt;br /&gt;
&lt;br /&gt;
We use the R statistical software for our calculation of site suitability (i.e. development potential) in FUTURES. R is a free software environment for statistical computing and graphics. If you don't have R, or you have older an version, please download and install the software from [http://archive.linux.duke.edu/cran/ install R] and be sure to additionally add these required packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
install.packages(c(&amp;quot;MuMIn&amp;quot;, &amp;quot;lme4&amp;quot;, &amp;quot;optparse&amp;quot;, &amp;quot;rgrass7&amp;quot;))&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== MS Windows ====&lt;br /&gt;
We will be using GRASS GIS 7.0.3 that can be found here [https://trac.osgeo.org/osgeo4w/ OSGeo4W] package manager.&lt;br /&gt;
Please install the latest stable GRASS GIS 7 version and the SciPy Python package using the ''Advanced install'' option.&lt;br /&gt;
A guide with step by step screen shot instructions is available [https://docs.google.com/presentation/d/1yEGpriBne7RvjB35HI6GecNwO1P1y2nRGqDThqoNnCE/edit?usp=sharing here].&lt;br /&gt;
&lt;br /&gt;
In order for GRASS to be able to find R executables, GRASS must be on the PATH variable. Follow this [solution] to make R accessible from GRASS permanently.&lt;br /&gt;
A simple but temporary solution is to open GRASS GIS and paste this in the black terminal:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set PATH=%PATH%;C:\Program Files\R\R-3.0.2\bin&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This has to be repeated after restarting GRASS session.&lt;br /&gt;
&lt;br /&gt;
==== Ubuntu Linux ====&lt;br /&gt;
Install GRASS GIS from packages:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install grass&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Workshop data ==&lt;br /&gt;
Download [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip sample dataset] containing GRASS GIS location with:&lt;br /&gt;
* digital elevation model ([http://nationalmap.gov/elevation.html NED])&lt;br /&gt;
* [http://www.mrlc.gov/ NLCD] 2001, 2011&lt;br /&gt;
* NLCD 1992/2001 Retrofit Land Cover Change Product&lt;br /&gt;
* transportation network ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* county boundaries ([http://www.census.gov/geo/maps-data/data/tiger-line.html TIGER])&lt;br /&gt;
* protected areas ([http://www.conservationgateway.org/ConservationByGeography/NorthAmerica/UnitedStates/edc/reportsdata/terrestrial/secured/Pages/default.aspx  Secured Lands])&lt;br /&gt;
* cities as points (USGS)&lt;br /&gt;
&lt;br /&gt;
In addition, download [http://fatra.cnr.ncsu.edu/futures/futures_Asheville_files.zip population information as text files]:&lt;br /&gt;
* county population past estimates and future projections ([https://www.osbm.nc.gov/demog/county-projections NC OSBM]) per county (nonspatial)&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS introduction =&lt;br /&gt;
* Overview of GRASS GIS project: [https://grass.osgeo.org grass.osgeo.org]&lt;br /&gt;
* Overview of [https://grass.osgeo.org/grass71/manuals/grass_database.html GRASS database].&lt;br /&gt;
** ''GRASS database'': directory with Locations (projects)&lt;br /&gt;
** ''Location'': directory with Mapsets, defined by projection (spatial reference system)&lt;br /&gt;
** ''Mapset'': collection of maps&lt;br /&gt;
* Download the [http://fatra.cnr.ncsu.edu/futures/futures_ncspm_Asheville.zip workshop location]. Create (unless you already have it) a directory named &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt; (GRASS database) in your home folder (or Documents), unzip the downloaded data into this directory. You should have now Location &amp;lt;tt&amp;gt;futures_ncspm&amp;lt;/tt&amp;gt; in &amp;lt;tt&amp;gt;grassdata&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Launch GRASS and display raster, vector data, explore navigation, querying, adding legend, showing metadata&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=500 heights=250&amp;gt;Image:GRASS FUTURES startup.png|GRASS GIS 7.0.3 startup dialog with downloaded Location and Mapsets for FUTURES workshop&lt;br /&gt;
Image:GRASS FUTURES wxGUI display.png|Layer Manager and Map Display overview. Annotations show how to add raster layer, query, add legend.&lt;br /&gt;
Image:wxGUI_metadata_rinfo.png|Show raster map metadata by right click on layer&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* GRASS GIS has over [https://grass.osgeo.org/grass70/manuals/full_index.html 500 different modules] in the core distribution and over [https://grass.osgeo.org/grass70/manuals/addons/ 230 addon modules]&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
  {| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Prefix !! Function !! Example&lt;br /&gt;
|-&lt;br /&gt;
| r.* || raster processing || ''{{cmd|r.mapcalc}}'': map algebra&lt;br /&gt;
|-&lt;br /&gt;
| v.* || vector processing  || ''{{cmd|v.clean}}'': topological cleaning&lt;br /&gt;
|-&lt;br /&gt;
| i.* || imagery processing  || ''{{cmd|i.segment}}'': object recognition&lt;br /&gt;
|-&lt;br /&gt;
| db.* || database management || ''{{cmd|db.select}}'': select values from table&lt;br /&gt;
|-&lt;br /&gt;
| r3.* || 3D raster processing  || ''{{cmd|r3.stats}}'': 3D raster statistics&lt;br /&gt;
|-&lt;br /&gt;
| t.* || temporal data processing  || ''{{cmd|t.rast.aggregate}}'': temporal aggregation&lt;br /&gt;
|-&lt;br /&gt;
| g.* || general data management || ''{{cmd|g.rename}}'': renames map&lt;br /&gt;
|-&lt;br /&gt;
| d.* || display ||''{{cmd|d.rast}}'': display raster map&lt;br /&gt;
|}&amp;lt;/center&amp;gt;&lt;br /&gt;
* GRASS modules have GUI and command line interface. In this workshop we use commands to describe the workflow, but we can use both GUI and command line depending on personal preference. Look how {{cmd|wxGUI.modules|version=71|desc=GUI and command line interface}} represent the same tool.&amp;lt;br /&amp;gt;''Task:'' compute aspect (orientation) from provided digital elevation model using module {{cmd|r.slope.aspect}} using both module dialog and command line.&lt;br /&gt;
* How to find modules? Modules are organized by their functionality in wxGUI menu, or we can search for them in Search modules tab. If we already know which module to use, we can just type it in the wxGUI command console.&amp;lt;br \&amp;gt;&amp;lt;center&amp;gt;&amp;lt;gallery perrow=3 widths=380 heights=190&amp;gt;Image:wxGUI_menu_rinfo.png|Modules can be found in wxGUI menu&lt;br /&gt;
Image:wxGUI_module_search.png|You can search modules by name, description or keywords in ''Search modules'' tab&lt;br /&gt;
Image:wxGUI_console_completion.png|By typing prefix r. we make a list of modules starting with that prefix to show up.&amp;lt;/gallery&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- https://grasswiki.osgeo.org/wiki/File:Wxgui_command_line.png--&amp;gt;&lt;br /&gt;
* {{cmd|g.region|desc=Computational region}} - an important raster concept&lt;br /&gt;
** defined by region extent and raster resolution&lt;br /&gt;
** applies to all raster operations&lt;br /&gt;
** persists between GRASS session, can be different for different mapsets&lt;br /&gt;
** advantages: keeps your results consistent, avoid clipping, for computationally demanding tasks set region to smaller extent, check your result is good and then set the computational region to the entire study area and rerun analysis&lt;br /&gt;
** run &amp;lt;code&amp;gt;g.region -p&amp;lt;/code&amp;gt; or in menu ''Settings'' - ''Region'' - ''Display region'' to see current region settings&lt;br /&gt;
[[File:WxGUI set region.png|700px|thumb|center|Simple ways to set computational region from GUI. On the left, set region to match raster map. On the right, select the highlighted option and then set region by drawing rectangle.]]&lt;br /&gt;
                                                                &lt;br /&gt;
* GRASS 3D view&lt;br /&gt;
&lt;br /&gt;
= Modeling with FUTURES =&lt;br /&gt;
== Initial steps and data preparation ==&lt;br /&gt;
First we will set computational region of our analyses to an extent covering our study area and so that the cells are aligned with one of our landuse rasters:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;g.region raster=landuse_2011 -p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will derive urbanized areas from NLCD dataset for year 1992, 2001 and 2011&lt;br /&gt;
by extracting categories category 21 - 24 into a new binary map where developed is 1,&lt;br /&gt;
undeveloped 0 and NULL (no data) is area unsuitable for development (water, wetlands, protected areas).&lt;br /&gt;
First we will convert protected areas from vector to raster. We set&lt;br /&gt;
NULLs to zeros (for simpler raster algebra expression in the next step) using {{cmd|r.null}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=protected_areas output=protected_areas use=val&lt;br /&gt;
r.null map=protected_areas null=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then create rasters of developed/undeveloped areas using raster algebra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_1992 = if(landuse_1992 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_1992 &amp;lt;= 24, 1, if(landuse_1992 == 11 || landuse_1992 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2001 = if(landuse_2001 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2001 &amp;lt;= 24, 1, if(landuse_2001 == 11 || landuse_2001 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_2011 = if(landuse_2011 &amp;gt;= 21 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 24, 1, if(landuse_2011 == 11 || landuse_2011 &amp;gt;= 90 || protected_areas, null(), 0))&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will convert vector counties to raster with the values of the FIPS attribute which links to population file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area use=attr attribute_column=FIPS output=counties&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before further steps, we will set our working directory so that the input population files and text files&lt;br /&gt;
we are going to create are saved in one directory and easily accessible.&lt;br /&gt;
You can do that from menu ''Settings'' → ''GRASS working environment'' → ''Change working directory''.&lt;br /&gt;
Select (or create) a directory and move there the downloaded files &amp;lt;tt&amp;gt;population_projection.csv&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;population_trend.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Potential submodel ==&lt;br /&gt;
Module {{AddonCmd|r.futures.potential}} implements POTENTIAL submodel as a part of FUTURES land change model. POTENTIAL is implemented using a set of coefficients that relate a selection of site suitability factors to the probability of a place becoming developed. This is implemented using the parameter table in combination with maps of those site suitability factors (mapped predictors). The coefficients are obtained by conducting multilevel logistic regression in R with package lme4 where the coefficients may vary by county. The best model is selected automatically using dredge function from package [https://cran.r-project.org/web/packages/MuMIn/index.html MuMIn].&lt;br /&gt;
&lt;br /&gt;
First, we will derive couple of predictors. &lt;br /&gt;
=== Predictors ===&lt;br /&gt;
==== Slope ====&lt;br /&gt;
We will derive slope in degrees from digital elevation model using {{cmd|r.slope.aspect}} module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;r.slope.aspect elevation=elevation_30m slope=slope&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from lakes/rivers ====&lt;br /&gt;
First we will extract [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water''] from 2011 NLCD dataset:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;water = if(landuse_2011 == 11, 1, null())&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we compute the distance to water with module {{cmd|r.grow.distance}} and set color table to shades of blue:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.grow.distance input=water distance=dist_to_water&lt;br /&gt;
r.colors -n map=dist_to_water color=blues&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance from protected areas ====&lt;br /&gt;
We will use raster protected of protected areas we already created, but we will set NULL values to zero.&lt;br /&gt;
We compute the distance to protected areas with module {{cmd|r.grow.distance}} and set color table from green to red:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=protected_areas setnull=0&lt;br /&gt;
r.grow.distance input=protected_areas distance=dist_to_protected&lt;br /&gt;
r.colors map=dist_to_protected color=gyr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Forests ====&lt;br /&gt;
We will smooth the transition between forest and other land use, see NLCD [http://www.mrlc.gov/nlcd11_leg.php category ''Open Water'']:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;forest = if(landuse_2011 &amp;gt;= 41 &amp;amp;&amp;amp; landuse_2011 &amp;lt;= 43, 1, 0)&amp;quot;&lt;br /&gt;
r.neighbors -c input=forest output=forest_smooth size=15 method=average&lt;br /&gt;
r.colors map=forest_smooth color=ndvi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Travel time to cities ====&lt;br /&gt;
Here we will compute travel time to cities (with population &amp;gt; 5000)&lt;br /&gt;
as cumulative cost distance where cost is defined as travel time on roads.&lt;br /&gt;
First we specify the speed on different types of roads.&lt;br /&gt;
We copy the roads raster into our mapset so that we can change it&lt;br /&gt;
by adding a new attribute field &amp;lt;tt&amp;gt;speed&amp;lt;/tt&amp;gt;. Then we assign speed values (km/h) based on the type of road:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.copy vector=roads,myroads&lt;br /&gt;
v.db.addcolumn map=myroads columns=&amp;quot;speed double precision&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=50 where=&amp;quot;MTFCC = 'S1400'&amp;quot;&lt;br /&gt;
v.db.update map=myroads column=speed value=100 where=&amp;quot;MTFCC IN ('S1100', 'S1200')&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we rasterize the selected road types using the speed values from the attribute table as raster values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=myroads type=line where=&amp;quot;MTFCC IN ('S1100', 'S1200', 'S1400')&amp;quot; output=roads_speed use=attr attribute_column=speed&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We set the rest of the area to low speed and recompute the speed as time to travel through a 30m cell in minutes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.null map=roads_speed null=5&lt;br /&gt;
r.mapcalc &amp;quot;roads_travel_time = 1.8 / roads_speed&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally we compute the travel time to larger cities using {{cmd|r.cost}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.cost input=roads_travel_time output=travel_time_cities start_points=cities&lt;br /&gt;
r.colors map=travel_time_cities color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Road density ====&lt;br /&gt;
We will rasterize roads and use moving window analysis ({{cmd|r.neighbors}}) to compute road density:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads output=roads use=val type=line&lt;br /&gt;
r.null map=roads null=0&lt;br /&gt;
r.neighbors -c input=roads output=road_dens size=25 method=average&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Distance to interchanges ====&lt;br /&gt;
&lt;br /&gt;
We will consider TIGER roads of type &amp;lt;tt&amp;gt;Ramp&amp;lt;/tt&amp;gt; as interchanges, rasterize them and compute euclidean distance to them:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line where=&amp;quot;MTFCC = 'S1630'&amp;quot; output=interchanges use=val&lt;br /&gt;
r.grow.distance -m input=interchanges distance=dist_interchanges&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development pressure ===&lt;br /&gt;
&lt;br /&gt;
We compute development pressure with {{AddonCmd|r.futures.devpressure}}. Development pressure is a predictor based on number of neighboring developed cells within search distance, weighted by distance. The development pressure variable plays a special role in the model, allowing for a feedback between predicted change and change in subsequent steps.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_2 method=gravity size=7 gamma=2 scaling_factor=10&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_1 method=gravity size=10 gamma=1 scaling_factor=1&lt;br /&gt;
r.futures.devpressure -n input=urban_2011 output=devpressure_0_5 method=gravity size=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When gamma increases, development influence decreases more rapidly with distance.&lt;br /&gt;
Size is half the size of the moving window. When gamma is low, local development influences more distant places.&lt;br /&gt;
We will derive 3 layers with different gamma and size parameters for the potential statistical model.&lt;br /&gt;
&lt;br /&gt;
=== Rescaling variables ===&lt;br /&gt;
&lt;br /&gt;
First we will look at the ranges of our predictor variables by running a short Python code snippet in Python shell:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
for name in ['slope', 'dist_to_water', 'dist_to_protected', 'forest_smooth', 'travel_time_cities', 'road_dens', 'dist_interchanges', 'devpressure_0_5', 'devpressure_1']:&lt;br /&gt;
    minmax = grass.raster_info(name)&lt;br /&gt;
    print name, minmax['min'], minmax['max']&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will rescale some of our input variables:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_water_km = dist_to_water / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_to_protected_km = dist_to_protected / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;dist_interchanges_km = dist_interchanges / 1000&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;road_dens_perc = road_dens * 100&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;forest_smooth_perc = forest_smooth * 100&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Sampling ===&lt;br /&gt;
To sample only in the analyzed counties, we will clip development layer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_01_11 = if(urban_2011 == 1, if(urban_2001 == 0, 1, null()), 0)&amp;quot;&lt;br /&gt;
r.mapcalc &amp;quot;urban_change_clip = if(counties, urban_change_01_11)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To estimate the number of sampling points, we can use {{cmd|r.report}} to report number of developed/undeveloped cells and their ratio.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.report map=urban_change_clip units=h,c,p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will sample the predictors and the response variable with 5000 random points in undeveloped areas and 1000 points in developed area:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.sample.category input=urban_change_clip output=sampling sampled=counties,devpressure_0_5,devpressure_1,devpressure_2,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities npoints=5000,1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The attribute table can be exported as CSV file (not necessary step):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
v.db.select map=sampling columns=urban_change_clip,counties,devpressure_0_5,devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities separator=comma file=samples.csv&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Development potential ===&lt;br /&gt;
Now we find best model for predicting urbanization using {{AddonCmd|r.futures.potential}} which wraps an R script.&lt;br /&gt;
&lt;br /&gt;
We can run R [http://www.inside-r.org/packages/cran/MuMIn/docs/dredge dredge] function to find &amp;quot;best&amp;quot; model. We can specify minimum and maximum number of predictors the final model should use.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential -d input=sampling output=potential.csv columns=devpressure_1,slope,road_dens_perc,forest_smooth_perc,dist_to_water_km,dist_to_protected_km,dist_interchanges_km,travel_time_cities developed_column=urban_change_clip subregions_column=counties min_variables=4 &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we can play with different combinations of predictors, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_1,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can then open the output file &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt;, which is a CSV file with tabs as separators.&lt;br /&gt;
&lt;br /&gt;
For this tutorial, the final potential is created with:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potential input=sampling output=potential.csv columns=devpressure_2,road_dens_perc,slope,dist_interchanges_km,dist_to_water_km developed_column=urban_change_clip subregions_column=counties --o&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now visualize the suitability surface using module {{AddonCmd|r.futures.potsurface}}. It creates initial development potential (suitability) raster from predictors and model coefficients and serves only for evaluating development potential model. The values of the resulting raster range from 0 to 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.potsurface input=potential.csv subregions=counties output=suitability&lt;br /&gt;
r.colors map=suitability color=byr&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Demand submodel ==&lt;br /&gt;
First we will mask out roads so that they don't influence into per capita land demand relation.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=roads type=line output=roads_mask use=val&lt;br /&gt;
r.mask roads_mask -i&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will use {{AddonCmd|r.futures.demand}} which derives the population vs. development relation. The relation can be linear/logarithmic/logarithmic2/exponential/exponential approach.&lt;br /&gt;
Look for examples of the different relations in the manual.&lt;br /&gt;
&lt;br /&gt;
* linear: y = A + Bx&lt;br /&gt;
* logarithmic: y = A + Bln(x)&lt;br /&gt;
* logarithmic2: y = A + B * ln(x - C)&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
* exponential: y = Ae^(BX)&lt;br /&gt;
* exp_approach: y = (1 - e^(-A(x - B))) + C&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;(requires SciPy)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The format of the input population CSV files is described in the manual. It is important to have synchronized categories of subregions and the column headers of the CSV files (in our case FIPS number). How to simply generate the list of years (for which demand is computed) is described in {{AddonCmd|r.futures.demand}} manual, for example run this in Python console:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
','.join([str(i) for i in range(2011, 2036)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we can create the DEMAND file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand development=urban_1992,urban_2001,urban_2011 subregions=counties observed_population=population_trend.csv projected_population=population_projection.csv simulation_times=2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035 plot=plot_demand.pdf demand=demand.csv separator=comma&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your current working directory, you should find files &amp;lt;tt&amp;gt;plot_demand.png&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;demand.csv&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you have SciPy installed, you can experiment with other methods for fitting the functions:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.demand ... method=logarithmic2&lt;br /&gt;
r.futures.demand ... method=exp_approach&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If necessary, you can create a set of demand files produced by fitting each method separately and&lt;br /&gt;
then pick for each county the method which seems best and manually create a new demand file.&lt;br /&gt;
&lt;br /&gt;
When you are finished, remove the mask as it is not needed for the next steps.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.mask -r&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Patch calibration ==&lt;br /&gt;
Patch calibration can be a very time consuming computation. &lt;br /&gt;
Therefore we select only one county (Buncombe):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
v.to.rast input=counties type=area where=&amp;quot;FIPS == 37021&amp;quot; use=attr attribute_column=FIPS output=calib_county&lt;br /&gt;
g.region raster=calib_county zoom=calib_county&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to derive patches of new development by comparing historical and latest development.&lt;br /&gt;
We can keep only patches with minimum size 2 cells (1800 = 2 x 30 x 30 m).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=counties patch_sizes=patches.txt patch_threshold=1800  -l&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We obtained a file &amp;lt;tt&amp;gt;patches.txt&amp;lt;/tt&amp;gt; (used later in the PGA) - a patch size distribution file - containing sizes of all found patches.&lt;br /&gt;
&lt;br /&gt;
We can look at the distribution of the patch sizes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from matplotlib import pyplot as plt&lt;br /&gt;
with open('patches.txt') as f:&lt;br /&gt;
    patches = [int(patch) for patch in f.readlines()]&lt;br /&gt;
plt.hist(patches, 2000)&lt;br /&gt;
plt.xlim(0,50)&lt;br /&gt;
plt.show()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At this point, we start the calibration to get best parameters of patch shape &lt;br /&gt;
(for this tutorial, this step can be skipped and the suggested parameters are used).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; &lt;br /&gt;
style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap;&lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.calib development_start=urban_1992 development_end=urban_2011 subregions=calib_county patch_sizes=patches.txt calibration_results=calib.csv patch_threshold=1800 repeat=5 compactness_mean=0.1,0.3,0.5,0.7,0.9 compactness_range=0.05 discount_factor=0.1,0.3,0.5,0.7,0.9 predictors=road_dens_perc,forest_smooth_perc,dist_to_protected_km demand=demand.csv devpot_params=potential.csv num_neighbors=4 seed_search=2 development_pressure=devpressure_0_5 development_pressure_approach=gravity n_dev_neighbourhood=30 gamma=0.5 scaling_factor=0.1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== FUTURES simulation ==&lt;br /&gt;
We will switch back to our previous region:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
g.region raster=landuse_2011 -p&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we have all the inputs necessary for running {{AddonCmd|r.futures.pga}}:&lt;br /&gt;
&lt;br /&gt;
The entire command is here:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot; style=&amp;quot;white-space: pre-wrap; &lt;br /&gt;
white-space: -moz-pre-wrap; &lt;br /&gt;
white-space: -pre-wrap; &lt;br /&gt;
white-space: -o-pre-wrap; &lt;br /&gt;
word-wrap: break-word;&amp;quot;&amp;gt;&lt;br /&gt;
r.futures.pga subregions=counties developed=urban_2011 predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 demand=demand.csv discount_factor=0.3 compactness_mean=0.2 compactness_range=0.1 patch_sizes=patches.txt num_neighbors=4 seed_search=2 random_seed=1 output=final output_series=final&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Quick description ===&lt;br /&gt;
The command parameters and their values:&lt;br /&gt;
* raster map of counties with their categories&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... subregions=counties ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* raster of developed (1), undeveloped (0) and NULLs for undevelopable areas&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... developed=urban_2011 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* predictors selected with {{AddonCmd|r.futures.potential}} and their coefficients in a &amp;lt;tt&amp;gt;potential.csv&amp;lt;/tt&amp;gt; file. The order of predictors must match the order in the file and the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... predictors=slope,forest_smooth_perc,dist_interchanges_km,travel_time_cities devpot_params=potential.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* initial development pressure computed by {{AddonCmd|r.futures.devpressure}}, it's important to set here the same parameters&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... development_pressure=devpressure_1 n_dev_neighbourhood=10 development_pressure_approach=gravity gamma=1 scaling_factor=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* per capita land demand computed by {{AddonCmd|r.futures.demand}}, the categories of the counties must match raster &amp;lt;tt&amp;gt;counties&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... demand=demand.csv ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* patch parameters from the calibration step&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... discount_factor=0.3 compactness_mean=0.4 compactness_range=0.08 patch_sizes=patches.txt ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* recommended parameters for patch growing algorithm &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... num_neighbors=4 seed_search=2 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* set random seed  for repeatable results or set flag &amp;lt;tt&amp;gt;-s&amp;lt;/tt&amp;gt; to generate seed automatically&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
... random_seed=1 ...&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* specify final output map and optionally basename for intermediate raster maps&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
output=final output_series=final&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Scenarios ==&lt;br /&gt;
Scenarios involving policies that encourage infill versus sprawl can be explored using the &amp;lt;tt&amp;gt;incentive_power&amp;lt;/tt&amp;gt; parameter of {{AddonCmd|r.futures.pga}},&lt;br /&gt;
which uses a power function to transform the evenness of the probability gradient in POTENTIAL. You can change the power to a number between 0.25 and 4 to test urban sprawl/infill scenarios.&lt;br /&gt;
Higher power leads to infill behavior, lower power to urban sprawl.&lt;br /&gt;
&lt;br /&gt;
== Postprocessing ==&lt;br /&gt;
&lt;br /&gt;
Follow a [[Creating_animation_from_FUTURES_output_in_GRASS_GIS| tutorial how to make an animation from the results]].&lt;br /&gt;
&lt;br /&gt;
= GRASS GIS Python API =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Tutorial]]&lt;br /&gt;
[[Category: FUTURES]]&lt;br /&gt;
[[Category: Urban]]&lt;/div&gt;</summary>
		<author><name>⚠️Dbvanber</name></author>
	</entry>
</feed>