RHESSysWorkflows  1.33
Variables
ImportRasterMapIntoGRASS Namespace Reference

Import raster map already registered in metadata via EcohydroLib.RegisterRaster, into GRASS. More...

Variables

tuple RESAMPLE_METHODS = list(GRASS_RASTER_RESAMPLE_METHODS)
 
tuple typeChoices = list(RHESSysMetadata.RASTER_TYPES)
 
tuple parser = argparse.ArgumentParser(description='Import raster map already registered in metadata via EcohydroLib.RegisterRaster, into GRASS. Raster type must be one of RHESSysMetadata.RASTER_TYPES.')
 
string help = 'The configuration file. Must define section "GRASS" and option "GISBASE"'
 
string nargs = '+'
 
tuple args = parser.parse_args()
 
tuple cmdline = RHESSysMetadata.getCommandLine()
 
 configFile = None
 
tuple context = Context(args.projectDir, configFile)
 
 typeList = RHESSysMetadata.RASTER_TYPES
 
list methodList = [args.method[0] for t in typeList]
 
tuple manifest = RHESSysMetadata.readManifestEntries(context)
 Check for necessary information in metadata. More...
 
tuple metadata = RHESSysMetadata.readRHESSysEntries(context)
 
tuple grassMetadata = RHESSysMetadata.readGRASSEntries(context)
 
list demRast = grassMetadata['dem_rast']
 
tuple modulePath = context.config.get('GRASS', 'MODULE_PATH')
 
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')
 
list method = methodList[index]
 
tuple rasterPath = os.path.join(context.projectDir, manifest[t])
 
string importName = "%s_tmp"
 
 overwrite = True
 
string mapcalcCmd = "%s=int(%s * %s)"
 
string grassEntryKey = "%s_rast"
 

Detailed Description

Import raster map already registered in metadata via EcohydroLib.RegisterRaster, into GRASS.

Raster type must be one of RHESSysMetadata.RASTER_TYPES.

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. One or more of the following metadata entry(ies) must be present in the manifest section of the metadata associated with the project directory: rhessysworkflows.metadata.RASTER_TYPES, currently: landcover roof_connectivity soil lai patch zone isohyet leafc rootdepth
  3. The following metadata entry(ies) must be present in the RHESSys section of the metadata associated with the project directory: grass_dbase grass_location grass_mapset

Post conditions

  1. Will write one or more the following entry(ies) to the GRASS section of metadata associated with the project directory: dem_rast landcover_rast roof_connectivity_rast soil_rast lai_rast patch_rast zone_rast
  2. Will delete one or more of the following entry(ies) from the RHESSys section of metadata associated with the project directory: stratum_defs landuse_defs soil_defs

Usage:

1 ImportRasterMapIntoGRASS.py -t RASTER_TYPE_1 [RASTER_TYPE_2 ... RASTER_TYPE_N] -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 ImportRasterMapIntoGRASS.args = parser.parse_args()
tuple ImportRasterMapIntoGRASS.cmdline = RHESSysMetadata.getCommandLine()
ImportRasterMapIntoGRASS.configFile = None
tuple ImportRasterMapIntoGRASS.context = Context(args.projectDir, configFile)
list ImportRasterMapIntoGRASS.demRast = grassMetadata['dem_rast']
tuple ImportRasterMapIntoGRASS.grassConfig = GRASSConfig(context, grassDbase, metadata['grass_location'], metadata['grass_mapset'])
tuple ImportRasterMapIntoGRASS.grassDbase = os.path.join(context.projectDir, metadata['grass_dbase'])
string ImportRasterMapIntoGRASS.grassEntryKey = "%s_rast"
tuple ImportRasterMapIntoGRASS.grassLib = GRASSLib(grassConfig=grassConfig)
tuple ImportRasterMapIntoGRASS.grassMetadata = RHESSysMetadata.readGRASSEntries(context)
string ImportRasterMapIntoGRASS.help = 'The configuration file. Must define section "GRASS" and option "GISBASE"'
string ImportRasterMapIntoGRASS.importName = "%s_tmp"
tuple ImportRasterMapIntoGRASS.manifest = RHESSysMetadata.readManifestEntries(context)

Check for necessary information in metadata.

string ImportRasterMapIntoGRASS.mapcalcCmd = "%s=int(%s * %s)"
tuple ImportRasterMapIntoGRASS.metadata = RHESSysMetadata.readRHESSysEntries(context)
list ImportRasterMapIntoGRASS.method = methodList[index]
list ImportRasterMapIntoGRASS.methodList = [args.method[0] for t in typeList]
tuple ImportRasterMapIntoGRASS.modulePath = context.config.get('GRASS', 'MODULE_PATH')
string ImportRasterMapIntoGRASS.nargs = '+'
ImportRasterMapIntoGRASS.overwrite = True
tuple ImportRasterMapIntoGRASS.parser = argparse.ArgumentParser(description='Import raster map already registered in metadata via EcohydroLib.RegisterRaster, into GRASS. Raster type must be one of RHESSysMetadata.RASTER_TYPES.')
tuple ImportRasterMapIntoGRASS.rasterPath = os.path.join(context.projectDir, manifest[t])
tuple ImportRasterMapIntoGRASS.RESAMPLE_METHODS = list(GRASS_RASTER_RESAMPLE_METHODS)
tuple ImportRasterMapIntoGRASS.result = grassLib.script.run_command('r.mask', flags='r')
tuple ImportRasterMapIntoGRASS.typeChoices = list(RHESSysMetadata.RASTER_TYPES)
ImportRasterMapIntoGRASS.typeList = RHESSysMetadata.RASTER_TYPES