RHESSysWorkflows  1.33
Variables
GenerateSoilTextureMap Namespace Reference

Query RHESSys ParamDB for soil definitions for a custom soil map. More...

Variables

tuple parser = argparse.ArgumentParser(description='Generate soil texture map for dataset in GRASS GIS')
 
string help = 'The configuration file. Must define section "GRASS" and option "GISBASE"'
 
tuple args = parser.parse_args()
 
tuple cmdline = RHESSysMetadata.getCommandLine()
 
 configFile = None
 
tuple context = Context(args.projectDir, configFile)
 
string soil_rast = 'soil_texture'
 
tuple manifest = RHESSysMetadata.readManifestEntries(context)
 
tuple metadata = RHESSysMetadata.readRHESSysEntries(context)
 
tuple grassMetadata = RHESSysMetadata.readGRASSEntries(context)
 
list demRast = grassMetadata['dem_rast']
 
tuple paths = RHESSysPaths(args.projectDir, metadata['rhessys_dir'])
 
tuple paramDbPath = os.path.join(context.projectDir, metadata['paramdb'])
 
tuple params = importlib.import_module('rhessys.params')
 
tuple paramConst = importlib.import_module('rhessys.constants')
 
tuple paramDB = params.paramDB(filename=paramDbPath)
 
tuple modulePath = context.config.get('GRASS', 'MODULE_PATH')
 
tuple moduleEtc = context.config.get('GRASS', 'MODULE_ETC')
 
tuple grassDbase = os.path.join(context.projectDir, metadata['grass_dbase'])
 
tuple grassConfig = GRASSConfig(context, grassDbase, metadata['grass_location'], metadata['grass_mapset'])
 
tuple grassLib = GRASSLib(grassConfig=grassConfig)
 
tuple result = grassLib.script.run_command('r.mask', flags='r')
 
tuple percentSandRasterPath = os.path.join(context.projectDir, manifest['soil_raster_pctsand'])
 
tuple percentClayRasterPath = os.path.join(context.projectDir, manifest['soil_raster_pctclay'])
 
tuple schemePath = os.path.join(moduleEtc, 'USDA.dat')
 
tuple soilTexture = os.path.join(modulePath, 'r.soils.texture')
 
tuple pipe = grassLib.script.pipe_command('r.stats', flags='licn', input=soil_rast)
 
dictionary textures = {}
 
tuple paramsFound
 

Detailed Description

Query RHESSys ParamDB for soil definitions for a custom soil map.

Import percent sand and percent clay raster maps into a GRASS location and generate soil texture map using r.soils.texture.

This software is provided free of charge under the New BSD License. Please see the following license information:

Copyright (c) 2013, University of North Carolina at Chapel Hill All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Author
Brian Miles brian.nosp@m._mil.nosp@m.es@un.nosp@m.c.ed.nosp@m.u

Pre conditions

  1. Configuration file must define the following sections and values: 'GRASS', 'GISBASE'
  2. The following metadata entry(ies) must be present in the GRASS section of the metadata associated with the project directory: dem_rast soil_rast
  3. The following metadata entry(ies) must be present in the RHESSys section of the metadata associated with the project directory: soil_rule paramdb paramdb_dir grass_dbase grass_location grass_mapset rhessys_dir

Post conditions

  1. Will write the following entry(ies) to the RHESSys section of metadata associated with the project directory: soil_defs

Usage:

1 GenerateCustomSoilDefinitions.py -p /path/to/project_dir
Note
EcoHydroWorkflowLib configuration file must be specified by environmental variable 'ECOHYDROWORKFLOW_CFG', or -i option must be specified.

This software is provided free of charge under the New BSD License. Please see the following license information:

Copyright (c) 2013, University of North Carolina at Chapel Hill All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Author
Brian Miles brian.nosp@m._mil.nosp@m.es@un.nosp@m.c.ed.nosp@m.u

Pre conditions

  1. Configuration file must define the following sections and values: 'GRASS', 'GISBASE'
  2. The following metadata entry(ies) must be present in the manifest section of the metadata associated with the project directory: soil_raster_pctsand [if defonly==False] soil_raster_pctclay [if defonly==False]
  3. The following metadata entry(ies) must be present in the RHESSys section of the metadata associated with the project directory: paramdb paramdb_dir grass_dbase grass_location grass_mapset rhessys_dir
  4. The following metadata entry(ies) must be present in the GRASS section of the metadata associated with the project directory: dem_rast soil_rast [if defonly==True]
  5. Requires r.soils.texture GRASS extension: http://grasswiki.osgeo.org/wiki/GRASS_AddOns#r.soils.texture

Post conditions

  1. Will write the following entry(ies) to the RHESSys section of metadata associated with the project directory: soil_defs
  2. Will write the following entry(ies) to the GRASS section of metadata associated with the project directory: soil_avgsand_rast [if defonly==False] soil_avgclay_rast [if defonly==False] soil_rast [if defonly==False]

Usage:

1 GenerateSoilTextureMap.py -p /path/to/project_dir
Note
EcoHydroWorkflowLib configuration file must be specified by environmental variable 'ECOHYDROWORKFLOW_CFG', or -i option must be specified.

This software is provided free of charge under the New BSD License. Please see the following license information:

Copyright (c) 2013, University of North Carolina at Chapel Hill All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Author
Brian Miles brian.nosp@m._mil.nosp@m.es@un.nosp@m.c.ed.nosp@m.u

Pre conditions

  1. Configuration file must define the following sections and values: 'GRASS', 'GISBASE'
  2. The following metadata entry(ies) must be present in the GRASS section of the metadata associated with the project directory: dem_rast soil_rast
  3. The following metadata entry(ies) must be present in the RHESSys section of the metadata associated with the project directory: paramdb paramdb_dir grass_dbase grass_location grass_mapset rhessys_dir

Post conditions

  1. Will write the following entry(ies) to the RHESSys section of metadata associated with the project directory: soil_rule

Usage:

1 GenerateCustomSoilDefinitions.py -p /path/to/project_dir
Note
EcoHydroWorkflowLib configuration file must be specified by environmental variable 'ECOHYDROWORKFLOW_CFG', or -i option must be specified.

Variable Documentation

tuple GenerateSoilTextureMap.args = parser.parse_args()
tuple GenerateSoilTextureMap.cmdline = RHESSysMetadata.getCommandLine()
GenerateSoilTextureMap.configFile = None
tuple GenerateSoilTextureMap.context = Context(args.projectDir, configFile)
list GenerateSoilTextureMap.demRast = grassMetadata['dem_rast']
tuple GenerateSoilTextureMap.grassConfig = GRASSConfig(context, grassDbase, metadata['grass_location'], metadata['grass_mapset'])
tuple GenerateSoilTextureMap.grassDbase = os.path.join(context.projectDir, metadata['grass_dbase'])
tuple GenerateSoilTextureMap.grassLib = GRASSLib(grassConfig=grassConfig)
tuple GenerateSoilTextureMap.grassMetadata = RHESSysMetadata.readGRASSEntries(context)
string GenerateSoilTextureMap.help = 'The configuration file. Must define section "GRASS" and option "GISBASE"'
tuple GenerateSoilTextureMap.manifest = RHESSysMetadata.readManifestEntries(context)
tuple GenerateSoilTextureMap.metadata = RHESSysMetadata.readRHESSysEntries(context)
tuple GenerateSoilTextureMap.moduleEtc = context.config.get('GRASS', 'MODULE_ETC')
tuple GenerateSoilTextureMap.modulePath = context.config.get('GRASS', 'MODULE_PATH')
tuple GenerateSoilTextureMap.paramConst = importlib.import_module('rhessys.constants')
tuple GenerateSoilTextureMap.paramDB = params.paramDB(filename=paramDbPath)
tuple GenerateSoilTextureMap.paramDbPath = os.path.join(context.projectDir, metadata['paramdb'])
tuple GenerateSoilTextureMap.params = importlib.import_module('rhessys.params')
tuple GenerateSoilTextureMap.paramsFound
Initial value:
1 = paramDB.search(paramConst.SEARCH_TYPE_CONSTRAINED, None, key, None, None, None, None, None, None, None, None,
2  limitToBaseClasses=True, defaultIdOverride=textures[key])
tuple GenerateSoilTextureMap.parser = argparse.ArgumentParser(description='Generate soil texture map for dataset in GRASS GIS')
tuple GenerateSoilTextureMap.paths = RHESSysPaths(args.projectDir, metadata['rhessys_dir'])
tuple GenerateSoilTextureMap.percentClayRasterPath = os.path.join(context.projectDir, manifest['soil_raster_pctclay'])
tuple GenerateSoilTextureMap.percentSandRasterPath = os.path.join(context.projectDir, manifest['soil_raster_pctsand'])
tuple GenerateSoilTextureMap.pipe = grassLib.script.pipe_command('r.stats', flags='licn', input=soil_rast)
tuple GenerateSoilTextureMap.result = grassLib.script.run_command('r.mask', flags='r')
tuple GenerateSoilTextureMap.schemePath = os.path.join(moduleEtc, 'USDA.dat')
list GenerateSoilTextureMap.soil_rast = 'soil_texture'
tuple GenerateSoilTextureMap.soilTexture = os.path.join(modulePath, 'r.soils.texture')
dictionary GenerateSoilTextureMap.textures = {}