help="The directory where landcover reclass rules can be found; must contain these files %s" % (str(RHESSysMetadata.LC_RULES),) )
parser.add_argument('-l', '--includeLaiRules', dest='includeLaiRules', required=False, action='store_true',
                    help='Make LAI map')
args = parser.parse_args()
cmdline = RHESSysMetadata.getCommandLine()

configFile = None
if args.configfile:
    configFile = args.configfile

context = Context(args.projectDir, configFile) 

# Check for necessary information in metadata
metadata = RHESSysMetadata.readRHESSysEntries(context)
studyArea = RHESSysMetadata.readStudyAreaEntries(context)
manifest = RHESSysMetadata.readManifestEntries(context)

paths = RHESSysPaths(args.projectDir, metadata['rhessys_dir'])

# Get path of place to store reclass rules
projectDirRuleDir = paths.getReclassRulesDirectory()

# Write prototype landcover reclass rules to the project directory
if args.buildPrototypeRules:
    sys.stdout.write('Generating prototype landcover reclass rules...')
    sys.stdout.flush()
    # Road rule
    roadRulePath = os.path.join(projectDirRuleDir, RHESSysMetadata.LC_RULE_ROAD)
    with open(roadRulePath, 'w') as f:
        f.write('22 23 24 31 = 1 road\n')
        f.write('* = NULL\n')
paths = RHESSysPaths(args.projectDir)

if not args.grassDbase:
    dbase = 'GRASSData'
else:
    dbase = args.grassDbase
grassDbase = os.path.join(context.projectDir, dbase)
location = None
if args.location:
    location = args.location
mapset = None
if args.mapset:
    mapset = args.mapset

# Check for necessary information in metadata
manifest = RHESSysMetadata.readManifestEntries(context)
if not 'dem' in manifest:
    sys.exit(
        "Metadata in project directory %s does not contain a DEM reference" %
        (context.projectDir, ))

studyArea = RHESSysMetadata.readStudyAreaEntries(context)
if not 'dem_srs' in studyArea:
    sys.exit(
        "Metadata in project directory %s does not contain DEM spatial reference"
        % (context.projectDir, ))
srsPattern = re.compile('EPSG:(\d+)')
result = srsPattern.search(studyArea['dem_srs'])
if not result:
    sys.exit("Spatial reference must be specified in the form 'EPSG:<number>'")
srs = int(result.group(1))