[GRASS-SVN] r65033 - grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Apr 9 06:07:44 PDT 2015


Author: osfraid
Date: 2015-04-09 06:07:43 -0700 (Thu, 09 Apr 2015)
New Revision: 65033

Modified:
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/r.green.biomassfor.impact.html
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/r.green.biomassfor.impact.py
Log:
add new version of r.green.biomassfor.impact and html file

Modified: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/r.green.biomassfor.impact.html
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/r.green.biomassfor.impact.html	2015-04-09 13:06:55 UTC (rev 65032)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/r.green.biomassfor.impact.html	2015-04-09 13:07:43 UTC (rev 65033)
@@ -0,0 +1,201 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>GRASS GIS manual: r.green.biomassfor.impact.py</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<link rel="stylesheet" href="grassdocs.css" type="text/css">
+</head>
+<body bgcolor="white">
+<div id="container">
+
+<a href="index.html"><img src="grass_logo.png" alt="GRASS logo"></a>
+<hr class="header">
+
+<h2>NOME</h2>
+<em><b>r.green.biomassfor.impact.py</b></em>  - Calculates impact and multifunctionality values
+<h2>PAROLE CHIAVE</h2>
+<h2>SINOPSI</h2>
+<div id="name"><b>r.green.biomassfor.impact.py</b><br></div>
+<b>r.green.biomassfor.impact.py --help</b><br>
+<div id="synopsis"><b>r.green.biomassfor.impact.py</b> [-<b>r</b>] <b>forest</b>=<em>name</em> <b>yield1</b>=<em>name</em> <b>yield_surface</b>=<em>name</em> <b>management</b>=<em>name</em> <b>treatment</b>=<em>name</em> <b>forest_roads</b>=<em>name</em> <b>energy_tops_hf</b>=<em>float</em> <b>energy_cormometric_vol_hf</b>=<em>float</em> <b>energy_tops_cop</b>=<em>float</em> <b>energy_map</b>=<em>name</em> <b>dhp</b>=<em>name</em>  [<b>output_sw_map</b>=<em>name</em>]   [<b>dtm</b>=<em>name</em>]   [<b>soiltx_map</b>=<em>name</em>]   [<b>soild_map</b>=<em>name</em>]   [<b>soilcmp_map</b>=<em>name</em>]   [<b>output_co2_map</b>=<em>name</em>]   [<b>output_aco2_map</b>=<em>name</em>]   [<b>output_netco2_map</b>=<em>name</em>]   [<b>dtm2</b>=<em>name</em>]   [<b>roughness</b>=<em>name</em>]   [<b>soilp2_map</b>=<em>name</em>]   [<b>tree_diam</b>=<em>name</em>]   [<b>tree_vol</b>=<em>name</em>]  <b>main_roads</b>=<em>name</em>  [<b>rivers</b>=<em>name</em>]   [<b>lakes</b>=<em>n
 ame</em>]   [<b>slp_min_cc</b>=<em>float</em>]   [<b>slp_max_cc</b>=<em>float</em>]   [<b>dist_max_cc</b>=<em>float</em>]   [<b>slp_max_fw</b>=<em>float</em>]   [<b>dist_max_fw</b>=<em>float</em>]   [<b>slp_max_cop</b>=<em>float</em>]   [<b>dist_max_cop</b>=<em>float</em>]   [<b>output_fr_map</b>=<em>name</em>]   [<b>firerisk_map</b>=<em>name</em>]   [<b>output_tot_re_map</b>=<em>name</em>]   [<b>output_imp_re_map</b>=<em>name</em>]   [<b>touristic_map</b>=<em>name</em>]   [<b>tev</b>=<em>name</em>]   [<b>field_tev</b>=<em>name</em>]   [<b>area_tev</b>=<em>name</em>]   [<b>output_tev</b>=<em>name</em>]   [<b>expl</b>=<em>name</em>]   [<b>impact</b>=<em>float</em>]   [<b>base</b>=<em>name</em>]   [--<b>overwrite</b>]  [--<b>help</b>]  [--<b>verbose</b>]  [--<b>quiet</b>]  [--<b>ui</b>] 
+</div>
+
+<div id="flags">
+<h3>Flag:</h3>
+<dl>
+<dt><b>-r</b></dt>
+<dd>Remove all operational maps</dd>
+
+<dt><b>--overwrite</b></dt>
+<dd>Permetti al file di output di sovrascrivere file esistenti</dd>
+<dt><b>--help</b></dt>
+<dd>Print usage summary</dd>
+<dt><b>--verbose</b></dt>
+<dd>Output verboso del modulo</dd>
+<dt><b>--quiet</b></dt>
+<dd>Output quieto del modulo</dd>
+<dt><b>--ui</b></dt>
+<dd>Force launching GUI dialog</dd>
+</dl>
+</div>
+
+<div id="parameters">
+<h3>Parametri:</h3>
+<dl>
+<dt><b>forest</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Name of vector parcel map</dd>
+<dd>Name of vector parcel map</dd>
+
+<dt><b>yield1</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Map of forest yield (cubic meters)</dd>
+
+<dt><b>yield_surface</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Map of stand surface (ha)</dd>
+
+<dt><b>management</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Map of forest management (1: high forest, 2:coppice)</dd>
+
+<dt><b>treatment</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Map of forest treatment (1: final felling, 2:thinning)</dd>
+
+<dt><b>forest_roads</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Raster map of forest roads (0, 1)</dd>
+
+<dt><b>energy_tops_hf</b>=<em>float</em> <b>[required]</b></dt>
+<dd>Energy for tops and branches in high forest in MWh/m³</dd>
+<dd>Default: <em>0.49</em></dd>
+
+<dt><b>energy_cormometric_vol_hf</b>=<em>float</em> <b>[required]</b></dt>
+<dd>Energy for tops and branches for high forest in MWh/m³</dd>
+<dd>Default: <em>1.97</em></dd>
+
+<dt><b>energy_tops_cop</b>=<em>float</em> <b>[required]</b></dt>
+<dd>Energy for tops and branches for Coppices in MWh/m³</dd>
+<dd>Default: <em>0.55</em></dd>
+
+<dt><b>energy_map</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Bioenergy map in MWh/m³</dd>
+
+<dt><b>dhp</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Name of vector district heating points</dd>
+<dd>Name of vector district heating points</dd>
+
+<dt><b>output_sw_map</b>=<em>name</em></dt>
+<dd>Name for output soil and water reduction bioenergy map</dd>
+
+<dt><b>dtm</b>=<em>name</em></dt>
+<dd>Name of Digital terrain model map</dd>
+
+<dt><b>soiltx_map</b>=<em>name</em></dt>
+<dd>Soil texture map</dd>
+
+<dt><b>soild_map</b>=<em>name</em></dt>
+<dd>Soil depth map</dd>
+
+<dt><b>soilcmp_map</b>=<em>name</em></dt>
+<dd>Soil compaction risk map</dd>
+
+<dt><b>output_co2_map</b>=<em>name</em></dt>
+<dd>Name for output CO2 emissions map</dd>
+
+<dt><b>output_aco2_map</b>=<em>name</em></dt>
+<dd>Name for output avoided CO2 emissions map</dd>
+
+<dt><b>output_netco2_map</b>=<em>name</em></dt>
+<dd>Name for output net CO2 emissions map</dd>
+
+<dt><b>dtm2</b>=<em>name</em></dt>
+<dd>Name of Digital terrain model map</dd>
+
+<dt><b>roughness</b>=<em>name</em></dt>
+<dd>Name of roughness map</dd>
+
+<dt><b>soilp2_map</b>=<em>name</em></dt>
+<dd>Soil production map</dd>
+
+<dt><b>tree_diam</b>=<em>name</em></dt>
+<dd>Average tree diameter map</dd>
+
+<dt><b>tree_vol</b>=<em>name</em></dt>
+<dd>Average tree volume map</dd>
+
+<dt><b>main_roads</b>=<em>name</em> <b>[required]</b></dt>
+<dd>Name of raster main roads</dd>
+<dd>Name of raster main roads</dd>
+
+<dt><b>rivers</b>=<em>name</em></dt>
+<dd>Raster map of rivers (0, 1)</dd>
+
+<dt><b>lakes</b>=<em>name</em></dt>
+<dd>Raster map of lakes (0, 1)</dd>
+
+<dt><b>slp_min_cc</b>=<em>float</em></dt>
+<dd>Percent slope lower limit with Cable Crane</dd>
+<dd>Default: <em>30.</em></dd>
+
+<dt><b>slp_max_cc</b>=<em>float</em></dt>
+<dd>Percent slope higher limit with Cable Crane</dd>
+<dd>Default: <em>100.</em></dd>
+
+<dt><b>dist_max_cc</b>=<em>float</em></dt>
+<dd>Maximum distance with Cable Crane</dd>
+<dd>Default: <em>800.</em></dd>
+
+<dt><b>slp_max_fw</b>=<em>float</em></dt>
+<dd>Percent slope higher limit with Forwarder</dd>
+<dd>Default: <em>30.</em></dd>
+
+<dt><b>dist_max_fw</b>=<em>float</em></dt>
+<dd>Maximum distance with Forwarder</dd>
+<dd>Default: <em>600.</em></dd>
+
+<dt><b>slp_max_cop</b>=<em>float</em></dt>
+<dd>Percent slope higher limit with other techniques for Coppices</dd>
+<dd>Default: <em>30.</em></dd>
+
+<dt><b>dist_max_cop</b>=<em>float</em></dt>
+<dd>Maximum distance with other techniques for Coppices</dd>
+<dd>Default: <em>600.</em></dd>
+
+<dt><b>output_fr_map</b>=<em>name</em></dt>
+<dd>Name for output reduction map of fire risk</dd>
+
+<dt><b>firerisk_map</b>=<em>name</em></dt>
+<dd>Fire risk map</dd>
+
+<dt><b>output_tot_re_map</b>=<em>name</em></dt>
+<dd>Name for output total recreational map</dd>
+
+<dt><b>output_imp_re_map</b>=<em>name</em></dt>
+<dd>Name for output improved recreational map</dd>
+
+<dt><b>touristic_map</b>=<em>name</em></dt>
+<dd>Touristic map</dd>
+
+<dt><b>tev</b>=<em>name</em></dt>
+<dd>Name of vector Total Economic Value map</dd>
+<dd>Name of vector Total Economic Value map</dd>
+
+<dt><b>field_tev</b>=<em>name</em></dt>
+<dd>Name of field with TEV value</dd>
+
+<dt><b>area_tev</b>=<em>name</em></dt>
+<dd>Area of TEV polygons</dd>
+
+<dt><b>output_tev</b>=<em>name</em></dt>
+<dd>TEV result</dd>
+
+<dt><b>expl</b>=<em>name</em></dt>
+<dd>Exploited areas [Energy/m2]</dd>
+
+<dt><b>impact</b>=<em>float</em></dt>
+<dd>Percentange of the impact</dd>
+<dd>Default: <em>0</em></dd>
+
+<dt><b>base</b>=<em>name</em></dt>
+<dd>Map of the reference situation for the impact</dd>
+
+</dl>
+</div>
+</body>
+</html>

Modified: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/r.green.biomassfor.impact.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/r.green.biomassfor.impact.py	2015-04-09 13:06:55 UTC (rev 65032)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.impact/r.green.biomassfor.impact.py	2015-04-09 13:07:43 UTC (rev 65033)
@@ -216,13 +216,6 @@
 #% required : no
 #% guisection: CO2 Emission
 #%end
-#%option G_OPT_R_INPUT
-#% key: mmfeatures
-#% type: string
-#% description: Raster map of morphometric features
-#% required : no
-#% guisection: CO2 Emission
-#%end
 #%option
 #% key: slp_min_cc
 #% type: double
@@ -420,6 +413,7 @@
     run_command("g.remove", type="raster", flags="f", name="yield_pix1")
     run_command("g.remove", type="raster", flags="f", name="yield_pix2")
     run_command("g.remove", type='raster', flags='f', name='slope__')
+    run_command("g.remove", type='raster', flags='f', name='slope___')
     run_command("g.remove", type='raster', flags='f', name='slope_deg__')
     run_command("g.remove", type='raster', flags='f', name='fell_HFtr1_em')
     run_command("g.remove", type='raster', flags='f', name='fell_HFtr2_em')
@@ -443,6 +437,7 @@
     YPIX = ''
 
     yield_surface=opts['yield_surface']
+    yield_=opts['yield1']
 
     expr_surf='analysis_surface='+opts['energy_map']+'>0'
     run_command('r.mapcalc', overwrite=ow,expression=expr_surf)
@@ -452,7 +447,7 @@
     #             output="techn_pix_comp")
 
     run_command("r.mapcalc", overwrite=ow,  
-        expression='yield_pix1 = (yield/'+yield_surface+')*((ewres()*nsres())/10000)')
+        expression='yield_pix1 = ('+yield_+'/'+yield_surface+')*((ewres()*nsres())/10000)')
 
 
     run_command("r.null", map="yield_pix1", null=0)
@@ -601,7 +596,6 @@
     main_roads=opts['main_roads']
     rivers=opts['rivers']
     lakes=opts['lakes']
-    mmfeatures=opts['mmfeatures']
 
 
     if tree_diam == '':
@@ -617,9 +611,13 @@
     yield_pix_process(opts, flgs)
 
     #control and process the slope map
-    run_command("r.slope.aspect", flags="a", overwrite=ow,elevation=opts['dtm2'], slope="slope__", format="percent")
+    run_command("r.slope.aspect", overwrite=ow,elevation=opts['dtm2'], slope="slope__", format="percent")
     run_command("r.slope.aspect", overwrite=ow,elevation=opts['dtm2'], slope="slope_deg__")
 
+    run_command("r.param.scale", overwrite=ow,
+                input=opts['dtm2'], output="morphometric_features",
+                size=3, method="feature")
+
     #process the preparatory maps
 
 
@@ -632,8 +630,10 @@
         run_command("r.mapcalc",overwrite=ow,expression='roughness=0')
         roughness='roughness'
 
+    run_command("r.null", map="yield_pix1", null=0)
+    run_command("r.null", map="morphometric_features", null=0)
     
-    exprmap='frict_surf_extr = pix_cross + if(yield_pix1<=0, 99999)'
+    exprmap='frict_surf_extr = pix_cross + if(yield_pix1<=0, 99999) + if(morphometric_features==6, 99999)'
     
     if rivers!='':
         run_command("r.null", map=rivers, null=0)
@@ -643,15 +643,12 @@
         run_command("r.null", map=lakes, null=0)
         exprmap+='+ if('+lakes+'>=1, 99999)'
 
-    if mmfeatures!='':
-        exprmap+='+ if('+mmfeatures+'==6, 99999)'
-        run_command("r.null", map=mmfeatures, null=0)
 
     run_command("r.mapcalc",overwrite=ow,expression=exprmap)
 
     run_command("r.cost", overwrite=ow,
             input="frict_surf_extr", output="extr_dist",
-            stop_points=vector_forest, start_rast="forest_roads",
+            stop_points=vector_forest, start_rast=forest_roads,
             max_cost=1500)
 
     CCEXTR = 'cable_crane_extraction = if('+yield_+'>0 && slope__>'+opts['slp_min_cc']+' && slope__<='+opts['slp_max_cc']+' && extr_dist<'+opts['dist_max_cc']+', 1)'
@@ -665,51 +662,64 @@
     run_command("r.mapcalc", overwrite=ow,expression=FWEXTR)
     run_command("r.mapcalc", overwrite=ow,expression=OEXTR)
 
+    run_command("r.mapcalc",overwrite=ow,expression="slope___=if(slope__<=100,slope__,100)")
 
+    # Calculate productivity
+    #view the paper appendix for the formulas
     run_command("r.mapcalc", overwrite=ow,
-                expression='fell_productHFtr1 = if('+management+' ==1 && ('+treatment+' ==1 || '+treatment+' ==99999) && '+tree_diam+' <99999,(cable_crane_extraction*(42-(2.6*'+tree_diam+'))/(-20))*1.65*(1-(slope__/100)), if('+management+' ==1 && ('+treatment+' ==1 || '+treatment+' ==99999) && '+tree_diam+' == 99999,(cable_crane_extraction*(42-(2.6*35))/(-20))*1.65*(1-(slope__/100))))')
+                expression='fell_productHFtr1 = if('+management+' ==1 && ('+treatment+' ==1 || '+treatment+' ==99999) && '+tree_diam+' <99999,(cable_crane_extraction*(42-(2.6*'+tree_diam+'))/(-20))*1.65*(1-(slope___/100)), if('+management+' ==1 && ('+treatment+' ==1 || '+treatment+' ==99999) && '+tree_diam+' == 99999,(cable_crane_extraction*(42-(2.6*35))/(-20))*1.65*(1-(slope___/100))))')
+    run_command("r.null", map="fell_productHFtr1", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='fell_productHFtr2 = if('+management+' ==1 && '+treatment+' ==2 && '+tree_diam+' <99999,(cable_crane_extraction*(42-(2.6*'+tree_diam+'))/(-20))*1.65*(1-((1000-(90*slope___)/(-80))/100)), if('+management+' ==1 && '+treatment+' ==2 && '+tree_diam+' == 99999,(cable_crane_extraction*(42-(2.6*35))/(-20))*1.65*(1-((1000-(90*slope___)/(-80))/100))))')
+    run_command("r.null", map="fell_productHFtr2", null=0)
+    run_command("r.mapcalc", overwrite=ow,
+                expression='fell_proc_productC = if('+management+' ==2 && '+soil_prod+' <99999,((0.3-(1.1*'+soil_prod+'))/(-4))*(1-(slope___/100)), if('+management+' ==2 && '+soil_prod+' == 99999,((0.3-(1.1*3))/(-4))*(1-(slope___/100))))')
+    run_command("r.null", map="fell_proc_productC", null=0)
+    ###### check fell_proc_productC ######
 
+    #9999: default value, if is present take into the process the average value (in case of fertility is 33)
 
-    run_command("r.mapcalc", overwrite=ow,
-                expression='fell_productHFtr2 = if('+management+' ==1 && '+treatment+' ==2 && '+tree_diam+' <99999,(cable_crane_extraction*(42-(2.6*'+tree_diam+'))/(-20))*1.65*(1-((1000-(90*slope__)/(-80))/100)), if('+management+' ==1 && '+treatment+' ==2 && '+tree_diam+' == 99999,(cable_crane_extraction*(42-(2.6*35))/(-20))*1.65*(1-((1000-(90*slope__)/(-80))/100))))')
+    #r.mapcalc --o 'fell_proc_productC = if(management at PERMANENT ==2 && soil_prod at PERMANENT <99999,((0.3-(1.1*soil_prod at PERMANENT))/(-4))*(1-(slope at PERMANENT/100)), if(management at PERMANENT ==2 && soil_prod at PERMANENT == 99999,((0.3-(1.1*3))/(-4))*(1-((1000-(90*slope at PERMANENT)/(-80))/100))))'
 
 
-    run_command("r.mapcalc", overwrite=ow,
-                expression='fell_proc_productC = if('+management+' ==2 && '+soil_prod+' <99999,((0.3-(1.1*'+soil_prod+'))/(-4))*(1-(slope__/100)), if('+management+' ==2 && '+soil_prod+' == 99999,((0.3-(1.1*3))/(-4))*(1-((1000-(90*slope__)/(-80))/100))))')
 
     run_command("r.mapcalc", overwrite=ow,
                 expression='proc_productHFtr1 = if('+management+' == 1 && ('+treatment+' == 1 || '+treatment+' ==99999) && '+tree_diam+'==99999, cable_crane_extraction*0.363*35^1.116, if('+management+' == 1 && ('+treatment+' == 1 || '+treatment+' ==99999) && '+tree_diam+'<99999, cable_crane_extraction*0.363*'+tree_diam+'^1.116))')
-
+    run_command("r.null", map="proc_productHFtr1", null=0)
     run_command("r.mapcalc", overwrite=ow,
-                expression='fell_proc_productHFtr1 = if('+management+' == 1 && ('+treatment+' == 1 || '+treatment+' ==99999) && '+tree_vol+'<9.999, forwarder_extraction*60/(1.5*(2.71^(0.1480-0.3894*2+0.0002*(slope__^2)-0.2674*2.5))+(1.0667+(0.3094/tree_vol)-0.1846*1)), if('+management+' == 1 && ('+treatment+' == 1 || '+treatment+' ==99999) && '+tree_vol+'==9.999, forwarder_extraction*60/(1.5*(2.71^(0.1480-0.3894*2+0.0002*(slope__^2)-0.2674*2.5))+(1.0667+(0.3094/0.7)-0.1846*1))))')
-
-
+                expression='fell_proc_productHFtr1 = if('+management+' == 1 && ('+treatment+' == 1 || '+treatment+' ==99999) && '+tree_vol+'<9.999, forwarder_extraction*60/(1.5*(2.71^(0.1480-0.3894*2+0.0002*(slope___^2)-0.2674*2.5))+(1.0667+(0.3094/'+tree_vol+')-0.1846*1)), if('+management+' == 1 && ('+treatment+' == 1 || '+treatment+' ==99999) && '+tree_vol+'==9.999, forwarder_extraction*60/(1.5*(2.71^(0.1480-0.3894*2+0.0002*(slope___^2)-0.2674*2.5))+(1.0667+(0.3094/0.7)-0.1846*1))))')
+    run_command("r.null", map="fell_proc_productHFtr1", null=0)
     run_command("r.mapcalc", overwrite=ow,
-                expression='fell_proc_productHFtr2 = if('+management+' == 1 && '+treatment+' == 2 && '+tree_vol+'<9.999, forwarder_extraction*60/(1.5*(2.71^(0.1480-0.3894*2+0.0002*(slope__^2)-0.2674*2.5))+(1.0667+(0.3094/'+tree_vol+')-0.1846*1))*0.8, if('+management+' == 1 && '+treatment+' == 2 && '+tree_vol+'==9.999, forwarder_extraction*60/(1.5*(2.71^(0.1480-0.3894*2+0.0002*(slope__^2)-0.2674*2.5))+(1.0667+(0.3094/0.7)-0.1846*1))*0.8))')
-
-
+                expression='fell_proc_productHFtr2 = if('+management+' == 1 && '+treatment+' == 2 && '+tree_vol+'<9.999, forwarder_extraction*60/(1.5*(2.71^(0.1480-0.3894*2+0.0002*(slope___^2)-0.2674*2.5))+(1.0667+(0.3094/'+tree_vol+')-0.1846*1))*0.8, if('+management+' == 1 && '+treatment+' == 2 && '+tree_vol+'==9.999, forwarder_extraction*60/(1.5*(2.71^(0.1480-0.3894*2+0.0002*(slope___^2)-0.2674*2.5))+(1.0667+(0.3094/0.7)-0.1846*1))*0.8))')
+    run_command("r.null", map="fell_proc_productHFtr2", null=0)
     run_command("r.mapcalc", overwrite=ow,
                 expression='chipp_prodHF = if('+management+' ==1 && ('+treatment+' == 1 ||  '+treatment+' == 99999), yield_pix/34, if('+management+' ==1 && '+treatment+' == 2, yield_pix/20.1))')
+    run_command("r.null", map="chipp_prodHF", null=0)
     run_command("r.mapcalc", overwrite=ow,
                 expression='chipp_prodC = if('+management+' ==2, yield_pix/45.9)')
+    run_command("r.null", map="chipp_prodC", null=0)
     run_command("r.mapcalc", overwrite=ow,
                 expression='chipp_prod = chipp_prodHF + chipp_prodC')
-
+    run_command("r.null", map="chipp_prod", null=0)
     run_command("r.mapcalc", overwrite=ow,
                 expression='extr_product_cableHF = if('+management+' ==1, cable_crane_extraction*149.33*(extr_dist^-1.3438)* extr_dist/8*0.75)')
-
+    run_command("r.null", map="extr_product_cableHF", null=0)
     run_command("r.mapcalc", overwrite=ow,
                 expression='extr_product_cableC = if('+management+' ==2, cable_crane_extraction*149.33*(extr_dist^-1.3438)* extr_dist/8*0.75)')
+    run_command("r.null", map="extr_product_cableC", null=0)
     run_command("r.mapcalc", overwrite=ow,
                 expression='extr_product_forw = forwarder_extraction*36.293*(extr_dist^-1.1791)* extr_dist/8*0.6')
+    run_command("r.null", map="extr_product_forw", null=0)
     run_command("r.mapcalc", overwrite=ow,
                 expression='extr_product_other = other_extraction*36.293*(extr_dist^-1.1791)* extr_dist/8*0.6')
-
-
-
-
+    run_command("r.null", map="extr_product_other", null=0)
+        
+    #cost of the transport distance
+    #this is becouse the wood must be sell to the collection point
+    #instead the residual must be brung to the heating points
+    
     run_command("r.mapcalc", overwrite=ow,
-                expression='tot_roads = '+forest_roads+' ||| '+main_roads+'')
+                expression='tot_roads = '+forest_roads+' ||| '+main_roads)
     run_command("r.null", map="tot_roads", null=0)
     run_command("r.mapcalc", overwrite=ow,
                 expression='tot_roads_neg = if(tot_roads==1,0,1)')
@@ -718,17 +728,20 @@
                 expression='frict_surf_tr1 =  frict_surf_extr*tot_roads_neg')
     run_command("r.mapcalc", overwrite=ow,
                 expression='frict_surf_tr = frict_surf_tr1+(tot_roads*((ewres()+nsres())/2))')
+    #run_command("r.null", map=dhp, null=0)
+    try:
+        run_command("r.cost", overwrite=ow, input="frict_surf_tr",
+                    output="tot_dist", stop_points=opts['forest'], start_points=dhp,
+                    max_cost=100000)
+        run_command("r.mapcalc", overwrite=ow,
+                    expression='transp_dist = tot_dist -  extr_dist')
+    except:
+        run_command("r.mapcalc", overwrite=ow,
+                    expression='transp_dist = extr_dist')
 
-    run_command("r.cost", overwrite=ow, input="frict_surf_tr",
-                output="tot_dist", stop_points=vector_forest, start_points=dhp,
-                max_cost=100000)
     run_command("r.mapcalc", overwrite=ow,
-                expression='transp_dist = tot_dist -  extr_dist')
-    run_command("r.mapcalc", overwrite=ow,
                 expression='transport_prod = if(('+treatment+' == 1 ||  '+treatment+' == 99999), ((transp_dist/1000/30)*(yield_pix*1/32)*2), if('+management+' ==1 && '+treatment+' == 2, ((transp_dist/1000/30)*(yield_pix*2.7/32)*2)))')
 
-
-
     # Avoided carbon dioxide emission
     run_command("r.mapcalc", overwrite=ow,
                 expression='fell_HFtr1_em = yield_pix/fell_productHFtr1*4.725')



More information about the grass-commit mailing list