[GRASS-SVN] r68010 - in grass-addons/grass7/raster/r.futures: . r.futures.potential r.futures.potsurface

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Mar 5 19:20:35 PST 2016


Author: annakrat
Date: 2016-03-05 19:20:34 -0800 (Sat, 05 Mar 2016)
New Revision: 68010

Added:
   grass-addons/grass7/raster/r.futures/r.futures.potsurface/
   grass-addons/grass7/raster/r.futures/r.futures.potsurface/Makefile
   grass-addons/grass7/raster/r.futures/r.futures.potsurface/r.futures.potsurface.html
   grass-addons/grass7/raster/r.futures/r.futures.potsurface/r.futures.potsurface.py
   grass-addons/grass7/raster/r.futures/r.futures.potsurface/r_futures_potsurface.png
Modified:
   grass-addons/grass7/raster/r.futures/Makefile
   grass-addons/grass7/raster/r.futures/r.futures.potential/r.futures.potential.html
Log:
r.futures: add r.futures.potsurface and improve r.futures.potential man page

Modified: grass-addons/grass7/raster/r.futures/Makefile
===================================================================
--- grass-addons/grass7/raster/r.futures/Makefile	2016-03-06 02:02:41 UTC (rev 68009)
+++ grass-addons/grass7/raster/r.futures/Makefile	2016-03-06 03:20:34 UTC (rev 68010)
@@ -7,6 +7,7 @@
 		r.futures.devpressure \
 		r.futures.demand \
 		r.futures.potential \
+		r.futures.potsurface \
 		r.futures.pga
 
 include $(MODULE_TOPDIR)/include/Make/Dir.make

Modified: grass-addons/grass7/raster/r.futures/r.futures.potential/r.futures.potential.html
===================================================================
--- grass-addons/grass7/raster/r.futures/r.futures.potential/r.futures.potential.html	2016-03-06 02:02:41 UTC (rev 68009)
+++ grass-addons/grass7/raster/r.futures/r.futures.potential/r.futures.potential.html	2016-03-06 03:20:34 UTC (rev 68010)
@@ -9,12 +9,35 @@
 
 The coefficients are obtained by conducting multilevel logistic regression in R
 with package <a href="https://cran.r-project.org/web/packages/lme4/index.html">lme4</a>
-where the coefficients may vary by county.
+where the coefficients may vary by subregions.
 The best model is selected automatically using <tt>dredge</tt>
 function from package
 <a href="https://cran.r-project.org/web/packages/MuMIn/index.html">MuMIn</a>
 (which has numerous caveats).
 
+<p>
+Module <em>r.futures.potential</em> can run it two modes. Without the <b>-d</b>
+flag, it uses all the given predictors to construct the model. With <b>-d</b>
+flag, it evaluates all the different combinations of predictors
+and picks the best one based on AIC.
+
+<h3>Format</h3>
+The format of the output file is a CSV file (but with tabs as delimiters).
+The header contains the names of the predictor maps and the first column
+contains the identifiers of the subregions. The order of columns is important,
+the second column represents intercept, the third development pressure and
+then the predictors.
+
+<pre>
+ID	Intercept	devpressure_0_5	slope	road_dens_perc	forest_smooth_perc ...
+37037	-1.873	12.595	-0.0758	0.0907	-0.0223	...
+37063	-2.039	12.595	-0.0758	0.0907	-0.0223	...
+37069	-1.795	12.595	-0.0758	0.0907	-0.0223	...
+37077	-1.264	12.595	-0.0758	0.0907	-0.0223	...
+37085	-1.925	12.595	-0.0758	0.0907	-0.0223	...
+...
+</pre>
+
 <h2>NOTES</h2>
 Note that this module is designed to automate the FUTURES workflow by brute-force
 selection of model, which has numerous caveats.
@@ -26,6 +49,7 @@
 <a href="r.futures.html">FUTURES</a>,
 <em><a href="r.futures.pga.html">r.futures.pga</a></em>,
 <em><a href="r.futures.devpressure.html">r.futures.devpressure</a></em>,
+<em><a href="r.futures.potsurface.html">r.futures.potsurface</a></em>,
 <em><a href="r.futures.demand.html">r.futures.demand</a></em>,
 <em><a href="r.futures.calib.html">r.futures.calib</a></em>,
 <em><a href="r.sample.category.html">r.sample.category</a></em>

Added: grass-addons/grass7/raster/r.futures/r.futures.potsurface/Makefile
===================================================================
--- grass-addons/grass7/raster/r.futures/r.futures.potsurface/Makefile	                        (rev 0)
+++ grass-addons/grass7/raster/r.futures/r.futures.potsurface/Makefile	2016-03-06 03:20:34 UTC (rev 68010)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = r.futures.potsurface
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script

Added: grass-addons/grass7/raster/r.futures/r.futures.potsurface/r.futures.potsurface.html
===================================================================
--- grass-addons/grass7/raster/r.futures/r.futures.potsurface/r.futures.potsurface.html	                        (rev 0)
+++ grass-addons/grass7/raster/r.futures/r.futures.potsurface/r.futures.potsurface.html	2016-03-06 03:20:34 UTC (rev 68010)
@@ -0,0 +1,54 @@
+<h2>DESCRIPTION</h2>
+Module <em>r.futures.potsurface</em> is a support tool for
+computing development probability surface based on maps and coefficients
+selected by <em><a href="r.futures.potential.html">r.futures.potential</a></em>.
+It computes the initial probability surface used in the patch growing algorithm in
+<em><a href="r.futures.pga.html">r.futures.pga</a></em>.
+It is not necessary to use this module, however it is useful to inspect
+the potential surface to better understand the input data
+and how the predictors influence the probability.
+The values range from 0 (unlikely to be developed) to 1 (high probability of development).
+<p>
+The inputs are the output file from <em><a href="r.futures.potential.html">r.futures.potential</a></em>
+and the name of the <b>subregions</b> raster map.
+
+
+<h2>EXAMPLES</h2>
+<div class="code"><pre>
+r.futures.potsurface input=potential.csv subregions=counties output=pot_surface
+</pre></div>
+<center>
+<img src="r_futures_potsurface.png">
+<p>
+Figure: We can visualize the potential surface in 3D and drape raster
+representing developed (red) and undeveloped (green) cells over it.
+</center>
+
+<h2>SEE ALSO</h2>
+
+<a href="r.futures.html">FUTURES</a>,
+<em><a href="r.futures.pga.html">r.futures.pga</a></em>,
+<em><a href="r.futures.potential.html">r.futures.potential</a></em>,
+<em><a href="r.futures.devpressure.html">r.futures.devpressure</a></em>,
+<em><a href="r.futures.demand.html">r.futures.demand</a></em>,
+<em><a href="r.futures.calib.html">r.futures.calib</a></em>,
+<em><a href="r.sample.category.html">r.sample.category</a></em>
+
+<h2>REFERENCES</h2>
+<ul>
+<li>
+    Meentemeyer, R. K., Tang, W., Dorning, M. A., Vogler, J. B., Cunniffe, N. J., & Shoemaker, D. A. (2013).
+    <a href="http://dx.doi.org/10.1080/00045608.2012.707591">FUTURES: Multilevel Simulations of Emerging
+    Urban-Rural Landscape Structure Using a Stochastic Patch-Growing Algorithm</a>.
+    Annals of the Association of American Geographers, 103(4), 785-807.
+<li>Dorning, M. A., Koch, J., Shoemaker, D. A., & Meentemeyer, R. K. (2015).
+   <a href="http://dx.doi.org/10.1016/j.landurbplan.2014.11.011">Simulating urbanization scenarios reveals
+    tradeoffs between conservation planning strategies</a>.
+    Landscape and Urban Planning, 136, 28-39.</li>
+</ul>
+
+<h2>AUTHOR</h2>
+
+Anna Petrasova, <a href="http://geospatial.ncsu.edu/osgeorel/">NCSU OSGeoREL</a><br>
+
+<p><i>Last changed: $Date: 2015-02-12 14:32:45 -0500 (Thu, 12 Feb 2015) $</i>

Added: grass-addons/grass7/raster/r.futures/r.futures.potsurface/r.futures.potsurface.py
===================================================================
--- grass-addons/grass7/raster/r.futures/r.futures.potsurface/r.futures.potsurface.py	                        (rev 0)
+++ grass-addons/grass7/raster/r.futures/r.futures.potsurface/r.futures.potsurface.py	2016-03-06 03:20:34 UTC (rev 68010)
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+##############################################################################
+#
+# MODULE:       r.futures.potsurface
+#
+# AUTHOR(S):    Anna Petrasova (kratochanna gmail.com)
+#
+# PURPOSE:      FUTURES Potential surface for visualization
+#
+# COPYRIGHT:    (C) 2016 by the GRASS Development Team
+#
+#               This program is free software under the GNU General Public
+#               License (>=v2). Read the file COPYING that comes with GRASS
+#               for details.
+#
+##############################################################################
+
+#%module
+#% description: Module for computing development potential surface from CSV file created by r.futures.potential and predictors
+#% keyword: raster
+#% keyword: statistics
+#%end
+#%option G_OPT_F_INPUT
+#% description: CSV file with coefficients
+#% required: yes
+#%end
+#%option G_OPT_R_INPUT
+#% key: subregions
+#% description: Raster map of subregions
+#% required: yes
+#%end
+#%option G_OPT_R_OUTPUT
+#% description: Output probability raster
+#%end
+
+
+import sys
+import grass.script as gscript
+
+
+def main():
+    csv = options['input']
+    output = options['output']
+    subregions = options['subregions']
+
+    data = {}
+    with open(csv, 'r') as f:
+        lines = f.readlines()
+    header = lines[0].strip().split('\t')
+    maps = header[2:]
+    for line in lines[1:]:
+#        line  = line.strip()
+        if not line:
+            continue
+        items = line.strip().split()
+        data[items[0]] = items[1:]
+
+    expr = 'eval(tmp = '
+    for i in data.keys():
+        expr += "if ({sub} == {ind}, {interc}".format(
+            sub=subregions, ind=i, interc=data[i][0])
+        for j, m in enumerate(maps):
+            expr += " + {coef} * {map}".format(coef=data[i][1 + j], map=m)
+        expr += ', '
+    expr += 'null()'
+    expr += ')' * len(data.keys())
+    expr += ')'  # for eval
+    expr += '\n {new} = 1.0 / (1.0 + exp(-tmp))'.format(new=output)
+    gscript.debug(1, expr)
+    gscript.mapcalc(expr)
+
+
+if __name__ == "__main__":
+    options, flags = gscript.parser()
+    sys.exit(main())

Added: grass-addons/grass7/raster/r.futures/r.futures.potsurface/r_futures_potsurface.png
===================================================================
(Binary files differ)


Property changes on: grass-addons/grass7/raster/r.futures/r.futures.potsurface/r_futures_potsurface.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream



More information about the grass-commit mailing list