RHESSysWorkflows  1.33
Namespaces | Functions | Variables
DelineateWatershed.py File Reference

Namespaces

 DelineateWatershed
 Use GRASS GIS to delineate a watershed for study area defined by a DEM.
 

Functions

def DelineateWatershed.positive_odd_integer (string)
 

Variables

float DelineateWatershed.AREA_THRESHOLD = 0.2
 
tuple DelineateWatershed.parser = argparse.ArgumentParser(description='Delineate watershed using GRASS GIS')
 
string DelineateWatershed.help = 'The configuration file. Must define section "GRASS" and option "GISBASE"'
 
tuple DelineateWatershed.args = parser.parse_args()
 
tuple DelineateWatershed.cmdline = RHESSysMetadata.getCommandLine()
 
 DelineateWatershed.configFile = None
 
tuple DelineateWatershed.context = Context(args.projectDir, configFile)
 
tuple DelineateWatershed.metadata = RHESSysMetadata.readRHESSysEntries(context)
 
tuple DelineateWatershed.studyArea = RHESSysMetadata.readStudyAreaEntries(context)
 
tuple DelineateWatershed.grassMetadata = RHESSysMetadata.readGRASSEntries(context)
 
list DelineateWatershed.demRast = grassMetadata['dem_rast']
 
tuple DelineateWatershed.demRows = int(studyArea['dem_rows'])
 
 DelineateWatershed.flowDirDem = demRast
 
tuple DelineateWatershed.modulePath = context.config.get('GRASS', 'MODULE_PATH')
 
tuple DelineateWatershed.grassDbase = os.path.join(context.projectDir, metadata['grass_dbase'])
 
tuple DelineateWatershed.grassConfig = GRASSConfig(context, grassDbase, metadata['grass_location'], metadata['grass_mapset'])
 
tuple DelineateWatershed.grassLib = GRASSLib(grassConfig=grassConfig)
 
tuple DelineateWatershed.result = grassLib.script.run_command('r.mask', flags='r')
 
 DelineateWatershed.flags = None
 
list DelineateWatershed.t_srs = studyArea['dem_srs']
 
string DelineateWatershed.point = "%f|%f\n"
 
tuple DelineateWatershed.findTheRiver = os.path.join(modulePath, 'r.findtheriver')
 
tuple DelineateWatershed.snappedCoords = result.split()
 
tuple DelineateWatershed.easting = float(snappedCoords[0])
 
tuple DelineateWatershed.northing = float(snappedCoords[1])
 
string DelineateWatershed.basinName = 'basin'
 
dictionary DelineateWatershed.rWatershedOptions
 
float DelineateWatershed.area = -1.0
 
tuple DelineateWatershed.areaRegex = re.compile('^\|1\|.*\|(.*)\|$')
 
tuple DelineateWatershed.pipe = grassLib.script.pipe_command('r.report', map=basinName, units='k')
 
tuple DelineateWatershed.m = areaRegex.match(line)