[GRASS-SVN] r53721 - in grass-addons/grass6/raster: . r.dam

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Nov 7 10:35:35 PST 2012


Author: robertomarzocchi
Date: 2012-11-07 10:35:34 -0800 (Wed, 07 Nov 2012)
New Revision: 53721

Added:
   grass-addons/grass6/raster/r.dam/
   grass-addons/grass6/raster/r.dam/r.dam
   grass-addons/grass6/raster/r.dam/readme.txt
Log:
r.dam grass6.4 script 

Added: grass-addons/grass6/raster/r.dam/r.dam
===================================================================
--- grass-addons/grass6/raster/r.dam/r.dam	                        (rev 0)
+++ grass-addons/grass6/raster/r.dam/r.dam	2012-11-07 18:35:34 UTC (rev 53721)
@@ -0,0 +1,218 @@
+#!/bin/sh
+############################################################################
+#
+# MODULE:	r.dam v.1 for GRASS 6.4 (march 2011)
+# AUTHOR(S):	Roberto Marzocchi
+# PURPOSE:	Creates the input of the r.damflood grass module
+# COPYRIGHT:	(C) 2012 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: script useful to create the input of the r.damflood grass module
+#%  keywords: Create an hypothetical dam 
+#%End
+#####################
+# INPUT
+#####################
+#%option
+#% key: DTM
+#% type: string
+#% gisprompt: old,cell,raster
+#% description: Input DTM raster map with the lake batimetry 
+#% required : yes
+#%end
+
+#%option
+#% key: DAM
+#% type: string
+#% gisprompt: old,vector,vector
+#% description: Input vector points with the dam location 
+#% required : yes
+#%end
+
+#% option
+#% key: UM
+#% type: string
+#% key_desc: U_M
+#% options:meters,kilometers,feet,miles,nautmiles  
+#% description: Units of distance
+#% required: yes
+#%end
+
+
+#%option 
+#% key: DH
+#% type: double
+#% gisprompt: new
+#% description: Dam height (above sea level)   
+#% required : yes
+#%end
+
+#%option 
+#% key: WH
+#% type: double
+#% gisprompt: new
+#% description: Water height within the reservoir (above sea level)   
+#% required : yes
+#%end
+
+#%option 
+#% key: East 
+#% type: double
+#% gisprompt: new
+#% description: East Coordinate of a point of the reservoir  
+#% required : yes
+#%end
+
+#%option 
+#% key: North 
+#% type: double
+#% gisprompt: new
+#% description: North Coordinate of a point of the reservoir  
+#% required : yes
+#%end
+
+#####################
+# output 
+#####################
+#%option
+#% key: DTM_DAM
+#% type: string
+#% gisprompt: new,cell,raster
+#% description: Output: name of the new DTM with the DAM. 
+#% required : yes
+#%end
+
+#%option
+#% key: Reservoir
+#% type: string
+#% gisprompt: new,cell,raster
+#% description: Output: name of the lake reservoir map that could be used in the r.damflood module 
+#% required : yes
+#%end
+
+#%option
+#% key: DAM_MAP
+#% type: string
+#% gisprompt: new,cell,raster
+#% description: Output: name of raster map with the dam elevation above the terrain 
+#% required : no
+#%end
+
+
+
+if  [ -z "$GISBASE" ]
+then
+	echo ""
+	echo "You must be in GRASS GIS to run this program"
+	echo ""
+	exit 1
+fi
+
+if [ "$1" != "@ARGS_PARSED@" ] ; then
+  exec g.parser "$0" "$@"
+fi
+
+$GRASS_VERBOSE
+PROG=`basename $0`
+
+
+#request control & test (only for imput map)
+if [ -z "$GIS_OPT_DTM" ] ; then
+  g.message -e "ERROR: DTM not specified"
+  exit 1
+fi 
+if [ -z "$GIS_OPT_DAM" ] ; then
+  g.message -e "ERROR: vector map with the DAM is not specified"
+  exit 1
+fi 
+if [ -z "$GIS_OPT_DH" ] ; then
+  g.message -e "ERROR: DAM height not specified"
+  exit 1
+fi  
+if [ -z "$GIS_OPT_WH" ] ; then
+  g.message -e "ERROR: Water height within the reservoir not specified"
+  exit 1
+fi
+if [ -z "$GIS_OPT_East" ] ; then
+  g.message -e "ERROR: East coordinate of a point within the reservoir not specified"
+  exit 1
+fi
+if [ -z "$GIS_OPT_North" ] ; then
+  g.message -e "ERROR: North coordinate of a point within the reservoir not specified"
+  exit 1
+fi
+
+if [ -z "$GIS_OPT_DTM_DAM" ] ; then
+  g.message -e "ERROR: Name of new DTM not specified"
+  exit 1
+fi
+
+if [ -z "$GIS_OPT_Reservoir" ] ; then
+  g.message -e "ERROR: Name of reservoir not specified"
+  exit 1
+fi
+
+dtm="$GIS_OPT_DTM"
+dam="$GIS_OPT_DAM"
+damlevel="$GIS_OPT_DH"
+waterlevel="$GIS_OPT_WH"
+EC="$GIS_OPT_East"
+NC="$GIS_OPT_North"
+UM="$GIS_OPT_UM"
+dtm_diga="$GIS_OPT_DTM_DAM"
+nome_lago="$GIS_OPT_Reservoir"
+total_dam="$GIS_OPT_DAM_MAP"
+# ****************************************************************
+#### cerco la risoluzione
+g.region -p > .resolution.txt
+exec 6<&0          
+exec < .resolution.txt  
+read a1 b1            
+read a2 b2
+read a3 b3
+read a4 b4
+read a5 b5
+read a6 b6
+read a7 b7
+read a8 b8
+read a9 b9
+exec 0<&6 6<&-
+res=$b9
+rm .resolution.txt
+#echo "res=" $res
+# ****************************************************************
+v.to.rast --overwrite --quiet input=$dam output=diga_rast_temp use=cat type=point,line
+
+r.mapcalc "diga_rast_temp=if(isnull(diga_rast_temp),0,diga_rast_temp)"
+r.mapcalc "$dtm_diga=if(diga_rast_temp>0&&$dtm<$damlevel,$damlevel,$dtm)"
+r.buffer -z --overwrite --quiet input=diga_rast_temp output=buffer_diga_temp distances=$res units=$UM
+
+
+r.mapcalc "buffer_diga_temp=if(isnull(buffer_diga_temp),0,buffer_diga_temp)"
+r.mapcalc "dtm_lago_temp=if(buffer_diga_temp>0&&$dtm<$damlevel,$damlevel,$dtm)"
+
+r.lake dem=dtm_lago_temp wl=$waterlevel lake=lago1_temp xy=$EC,$NC --overwrite --quiet >.abcdefg.txt
+rm .abcdefg.txt
+r.mapcalc "lago1_temp=if(isnull(lago1_temp),0,lago1_temp)"
+r.mapcalc "lago_ok_def=if($dtm_diga<$waterlevel&&(lago1_temp[-1,0]>0||lago1_temp[0,1]>0||lago1_temp[1,0]>0||lago1_temp[0,-1]>0),$waterlevel-$dtm_diga,lago1_temp)" 
+r.mapcalc "lago_volume_temp=lago_ok_def*ewres()*nsres()"
+# da controllare
+r.mapcalc "$total_dam=$dtm_diga-$dtm"
+r.sum rast=lago_volume_temp --quiet > .volume.txt 
+exec 6<&0          
+exec < .volume.txt  
+read a10 b10 c10
+exec 0<&6 6<&-
+volume=c10
+g.message "VOLUME = "$c10" "$UM"3"
+rm .volume.txt 
+
+g.remove rast=buffer_diga_temp,lago1_temp,lago_volume_temp,diga_rast_temp,dtm_lago_temp --quiet
+g.rename lago_ok_def,$nome_lago --quiet
+

Added: grass-addons/grass6/raster/r.dam/readme.txt
===================================================================
--- grass-addons/grass6/raster/r.dam/readme.txt	                        (rev 0)
+++ grass-addons/grass6/raster/r.dam/readme.txt	2012-11-07 18:35:34 UTC (rev 53721)
@@ -0,0 +1,6 @@
+Script file for grass6.4. 
+To use it copy in the grass cript folder.
+
+Description file actually not present.
+
+In case of problem contact the author (roberto.marzocchi at gter.it)



More information about the grass-commit mailing list