[GRASS-SVN] r65156 - grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Apr 27 08:57:55 PDT 2015


Author: osfraid
Date: 2015-04-27 08:57:55 -0700 (Mon, 27 Apr 2015)
New Revision: 65156

Modified:
   grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal/r.green.biomassfor.legal.py
Log:
bug fix to r.green.biomassfor.legal.py

Modified: grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal/r.green.biomassfor.legal.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal/r.green.biomassfor.legal.py	2015-04-27 15:57:22 UTC (rev 65155)
+++ grass-addons/grass7/raster/r.green/r.green.biomassfor/r.green.biomassfor.legal/r.green.biomassfor.legal.py	2015-04-27 15:57:55 UTC (rev 65156)
@@ -5,7 +5,7 @@
 #
 # MODULE:      r.green.biomassfor.legal
 # AUTHOR(S):   Sandro Sacchelli, Francesco Geri
-#              Converted to Python by Francesco Geri reviewed by Marco Ciolli
+#              Converted to Python by Pietro Zambelli and Francesco Geri, reviewed by Marco Ciolli
 # PURPOSE:     Calculates the potential Ecological Bioenergy contained in a forest
 # COPYRIGHT:   (C) 2013 by the GRASS Development Team
 #
@@ -15,56 +15,74 @@
 #
 #############################################################################
 #%Module
-#% description: Estimates legal bioenergy depending on yield, forest management and forest treatment
+#% description: Estimates potential bioenergy depending on forest increment, forest management and forest treatment
 #% keyword: raster
 #% keyword: biomass
+#% overwrite: yes
 #%End
+#%option G_OPT_V_INPUT
+#% key: forest
+#% type: string
+#% description: Name of vector parcel map
+#% label: Name of vector parcel map
+#% guisection: Base
+#%end
+#%option G_OPT_V_INPUT
+#% key: boundaries
+#% type: string
+#% description: Name of vector boundaries map (boolean map)
+#% label: Name of vector boundaries map (boolean map)
+#% guisection: Base
+#%end
 #%option
 #% key: energy_tops_hf
 #% type: double
 #% description: Energy for tops and branches in high forest in MWh/m³
 #% answer: 0.49
-#% required : yes
 #% guisection: Energy
 #%end
-#%option G_OPT_R_INPUT
-#% key: yield1
+#%option
+#% key: forest_column_yield
 #% type: string
-#% description: Map of forest yield (cubic meters)
-#% required : yes
+#% answer: yield
+#% description: Vector field of increment
+#% guisection: Base
 #%end
-#%option G_OPT_R_INPUT
-#% key: yield_surface
+#%option
+#% key: forest_column_yield_surface
 #% type: string
-#% description: Map of stand surface (ha)
-#% required : yes
+#% answer: yield_surface
+#% description: Vector field of stand surface (ha)
+#% guisection: Base
 #%end
-#%option G_OPT_R_INPUT
-#% key: management
+#%option 
+#% key: forest_column_management
 #% type: string
-#% description: Map of forest management (1: high forest, 2:coppice)
-#% required : yes
+#% answer: management
+#% description: Vector field of forest management (1: high forest, 2:coppice)
+#% guisection: Base
 #%end
-#%option G_OPT_R_INPUT
-#% key: treatment
+#%option
+#% key: forest_column_treatment
+#% answer: treatment
 #% type: string
-#% description: Map of forest treatment (1: final felling, 2:thinning)
-#% required : yes
+#% description: Vector field of forest treatment (1: final felling, 2:thinning)
+#% guisection: Base
 #%end
 #%option 
 #% key: output_basename
+#% answer: biomassfor
 #% type: string
 #% gisprompt: new
 #% description: Basename for potential bioenergy (HF,CC and total)
 #% key_desc : name
-#% required : yes
+#% guisection: Base
 #%end
 #%option
 #% key: energy_cormometric_vol_hf
 #% type: double
 #% description: Energy for the whole tree in high forest (tops, branches and stem) in MWh/m³
 #% answer: 1.97
-#% required : no
 #% guisection: Energy
 #%end
 #%option
@@ -72,7 +90,6 @@
 #% type: double
 #% description: Energy for tops and branches for Coppices in MWh/m³
 #% answer: 0.55
-#% required : no
 #% guisection: Energy
 #%end
 
@@ -86,18 +103,48 @@
 def main(opts, flgs):
     ow = overwrite()
 
-    output = opts['output_prefix']
+    output = opts['output_basename']
 
-    yield_=opts['yield1']
-    management=opts['management']
-    treatment=opts['treatment']
-    yield_surface=opts['yield_surface']
+    forest=opts['forest']
+    boundaries=opts['boundaries']
+    yield_=opts['forest_column_yield']
+    management=opts['forest_column_management']
+    treatment=opts['forest_column_treatment']
+    yield_surface=opts['forest_column_yield_surface']
 
     l_bioenergyHF=output+'_l_bioenergyHF'
     l_bioenergyC=output+'_l_bioenergyC'
     l_bioenergy=output+'_l_bioenergy'
 
+    ######## start import and convert ########
 
+
+    run_command("g.region",vect=boundaries)
+    run_command("v.to.rast", input=forest,output="yield", use="attr", attrcolumn=yield_,overwrite=True)
+    run_command("v.to.rast", input=forest,output="yield_surface", use="attr", attrcolumn=yield_surface,overwrite=True)
+    run_command("v.to.rast", input=forest,output="treatment", use="attr", attrcolumn=treatment,overwrite=True)
+    run_command("v.to.rast", input=forest,output="management", use="attr", attrcolumn=management,overwrite=True)
+
+
+    run_command("r.null", map='yield',null=0)
+    run_command("r.null", map='yield_surface',null=0)
+    run_command("r.null", map='treatment',null=0)
+    run_command("r.null", map='management',null=0)
+
+
+    ######## end import and convert ########
+
+
+    ######## temp patch to link map and fields ######
+
+    management="management"
+    treatment="treatment"
+    yield_surface="yield_surface"
+    yield_="yield"
+
+    ######## end temp patch to link map and fields ######
+
+
     #import pdb; pdb.set_trace()
     #treatment=1 final felling, treatment=2 thinning
     ECOHF = l_bioenergyHF+' = if('+management+'==1 && '+treatment+'==1 || '+management+' == 1 && '+treatment+'==99999, yield_pix1*%f, if('+management+'==1 && '+treatment+'==2, yield_pix1*%f + yield_pix1*%f))'                                     



More information about the grass-commit mailing list