[GRASS-SVN] r68100 - grass-addons/grass7/raster/r.futures/r.futures.pga

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Mar 21 18:22:47 PDT 2016


Author: annakrat
Date: 2016-03-21 18:22:47 -0700 (Mon, 21 Mar 2016)
New Revision: 68100

Modified:
   grass-addons/grass7/raster/r.futures/r.futures.pga/main.c
   grass-addons/grass7/raster/r.futures/r.futures.pga/r.futures.pga.html
Log:
r.futures: add new option for scenarios to r.futures.pga

Modified: grass-addons/grass7/raster/r.futures/r.futures.pga/main.c
===================================================================
--- grass-addons/grass7/raster/r.futures/r.futures.pga/main.c	2016-03-21 19:44:09 UTC (rev 68099)
+++ grass-addons/grass7/raster/r.futures/r.futures.pga/main.c	2016-03-22 01:22:47 UTC (rev 68100)
@@ -174,6 +174,7 @@
     float *predictors;
     /** multiplicative factor on the probabilities */
     float *consWeight;
+    float *stimulus;
 } t_Landscape;
 
 
@@ -190,6 +191,7 @@
     char *developedFile;
     char *devPressureFile;
     char *consWeightFile;
+    char *stimulus;
     char *probLookupFile;
     int nProbLookup;
     double *adProbLookup;
@@ -509,7 +511,7 @@
     bRet = 0;
     szBuff = (char *) G_malloc(_N_MAX_DYNAMIC_BUFF_LEN * sizeof(char));
     if (szBuff) {
-        for (j = 0; j < 3; j++) {
+        for (j = 0; j < 4; j++) {
             /* workaround to skip loading constraint map so that it can be omitted in input */
             if (j == 2) {
                 pLandscape->consWeight = NULL;
@@ -518,6 +520,13 @@
                 else
                     continue;
             }
+            if (j == 3) {
+                pLandscape->stimulus = NULL;
+                if (pParams->stimulus)
+                    pLandscape->stimulus = (float *)G_malloc(pLandscape->totalCells * sizeof(float));
+                else
+                    continue;
+            }
             switch (j) {        /* get correct filename */
             case 0:
                 strcpy(szFName, pParams->developedFile);
@@ -528,6 +537,9 @@
             case 2:
                 strcpy(szFName, pParams->consWeightFile);
                 break;
+            case 3:
+                strcpy(szFName, pParams->stimulus);
+                break;
             default:
                 G_fatal_error("readData(): shouldn't get here");
                 break;
@@ -605,6 +617,11 @@
                                 pLandscape->consWeight[i] = dVal;
                             }
                             break;
+                        case 3:
+                            if (pLandscape->stimulus) {
+                                pLandscape->stimulus[i] = dVal;
+                            }
+                            break;
                         default:
                             G_fatal_error("readData(): shouldn't get here");
                             break;
@@ -829,6 +846,7 @@
             pThis->bUntouched = 0;
             if (pThis->bUndeveloped) {
                 double consWeight = pLandscape->consWeight ? pLandscape->consWeight[thisPos] : 1;
+                double stimulus = pLandscape->stimulus ? pLandscape->stimulus[thisPos] : 0;
                 if (consWeight > 0.0) {
                     /* need to add this cell... */
 
@@ -877,6 +895,9 @@
                             probAdd = pParams->adProbLookup[lookupPos];
                         }
                         probAdd *= consWeight;
+                        // encourage development
+                        if (stimulus > 0)
+                            probAdd = probAdd + stimulus - probAdd * stimulus;
                         pNeighbours->aCandidates[pNeighbours->nCandidates].
                             probAdd = probAdd;
                         /* only actually add it if will ever transition */
@@ -1420,7 +1441,7 @@
             *consWeightFile, *addVariableFiles, *nDevNeighbourhood,
             *devpotParamsFile, *dumpFile, *outputSeries,
             *parcelSizeFile, *discountFactor,
-            /* *probLookupFile,*/ *incentivePower,
+            /* *probLookupFile,*/ *incentivePower, *stimulus,
             *patchMean, *patchRange, *numNeighbors, *seedSearch,
             *devPressureApproach, *alpha, *scalingFactor, *num_Regions,
             *numSteps, *indexFile, *controlFileAll, *seed;
@@ -1634,6 +1655,15 @@
         _("Values must be between 0 and 1, 1 means no constraint.");
     opt.consWeightFile->guisection = _("Scenarios");
 
+    opt.stimulus = G_define_standard_option(G_OPT_R_INPUT);
+    opt.stimulus->key = "stimulus";
+    opt.stimulus->required = NO;
+    opt.stimulus->label =
+        _("Raster map representing an increase in development potential for scenarios.");
+    opt.stimulus->description =
+        _("Values must be between 0 and 1, 0 means no increase.");
+    opt.stimulus->guisection = _("Scenarios");
+
     opt.seed = G_define_option();
     opt.seed->key = "random_seed";
     opt.seed->type = TYPE_INTEGER;
@@ -1700,6 +1730,7 @@
     sParams.developedFile = opt.developedFile->answer;
     sParams.devPressureFile = opt.devPressureFile->answer;
     sParams.consWeightFile = opt.consWeightFile->answer;
+    sParams.stimulus = opt.stimulus->answer;
     sParams.numAddVariables = 0;
     if (opt.numSteps->answer)
         sParams.nSteps = atoi(opt.numSteps->answer);
@@ -1852,6 +1883,8 @@
     G_free(sLandscape.predictors);
     if (sLandscape.consWeight)
         G_free(sLandscape.consWeight);
+    if (sLandscape.stimulus)
+        G_free(sLandscape.stimulus);
 
     return EXIT_SUCCESS;
 }
@@ -1912,6 +1945,7 @@
         if (pThis->nCellType == _CELL_VALID) {
             if (pThis->bUndeveloped) {
                 double consWeight = pLandscape->consWeight ? pLandscape->consWeight[i] : 1;
+                double stimulus = pLandscape->stimulus ? pLandscape->stimulus[i] : 0;
                 if (consWeight > 0.0) {
                     id = pThis->index_region;
                     if (pThis->index_region == -9999)
@@ -1952,6 +1986,11 @@
                     }
                     // discount by a conservation factor
                     pLandscape->asUndevs[id][pLandscape->num_undevSites[id]].logitVal *= consWeight;
+                    // encourage development
+                    if (stimulus > 0) {
+                        float logit = pLandscape->asUndevs[id][pLandscape->num_undevSites[id]].logitVal;
+                        pLandscape->asUndevs[id][pLandscape->num_undevSites[id]].logitVal = logit + stimulus - logit * stimulus;
+                    }
                     /* need to store this to put correct elements near top of list */
                     pLandscape->asUndevs[id][pLandscape->num_undevSites[id]].bUntouched = pThis->bUntouched;
                     if (pLandscape->asUndevs[id]

Modified: grass-addons/grass7/raster/r.futures/r.futures.pga/r.futures.pga.html
===================================================================
--- grass-addons/grass7/raster/r.futures/r.futures.pga/r.futures.pga.html	2016-03-21 19:44:09 UTC (rev 68099)
+++ grass-addons/grass7/raster/r.futures/r.futures.pga/r.futures.pga.html	2016-03-22 01:22:47 UTC (rev 68100)
@@ -66,6 +66,13 @@
 which results in decreased site suitability in areas,
 where the <b>constrain_weight</b> values are lower than 1.
 
+<p>Similarly, parameter <b>stimulus</b> (raster map from 0 to 1)
+enables to include policies to encourage growth in an area.
+Using this option results in increased site suitability in areas,
+where the <b>stimulus</b> values are greater than 0.
+The probability surface is transformed from initial probability <em>p</em>
+with stimulus <em>s</em> to p + s - p * s.
+
 <h3>Output</h3>
 After the simulation ends, raster specified in parameter <b>output</b> is written.
 If optional parameter <b>output_series</b> is specified, additional output
@@ -130,6 +137,7 @@
 <em><a href="r.futures.calib.html">r.futures.calib</a></em>,
 <em><a href="r.futures.demand.html">r.futures.demand</a></em>,
 <em><a href="r.futures.potential.html">r.futures.potential</a></em>,
+<em><a href="r.futures.parallelpga.html">r.futures.parallelpga</a></em>,
 <em><a href="r.sample.category.html">r.sample.category</a></em>
 
 



More information about the grass-commit mailing list