def checkMetadata(self, *args, **kwargs): """ Check to make sure the project directory has the necessary metadata to run this command. @note Concrete commands must call this super class method in their own implementation of checkMetadata(), and must call their implementation near the beginning of their run method. """ self.studyArea = RHESSysMetadata.readStudyAreaEntries(self.context) self.metadata = RHESSysMetadata.readRHESSysEntries(self.context)
def checkMetadata(self, *args, **kwargs): """ Check to make sure the project directory has the necessary metadata to run this command. @note Concrete commands must call this super class method in their own implementation of checkMetadata(), and must call their implementation near the beginning of their run method. """ self.studyArea = RHESSysMetadata.readStudyAreaEntries(self.context) self.metadata = RHESSysMetadata.readRHESSysEntries(self.context)
group.add_argument('-r', '--ruleDir', dest='ruleDir', required=False, 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')
# Check for necessary information in metadata metadata = RHESSysMetadata.readRHESSysEntries(context) if not 'grass_dbase' in metadata: sys.exit( "Metadata in project directory %s does not contain a GRASS Dbase" % (context.projectDir, )) if not 'grass_location' in metadata: sys.exit( "Metadata in project directory %s does not contain a GRASS location" % (context.projectDir, )) if not 'grass_mapset' in metadata: sys.exit( "Metadata in project directory %s does not contain a GRASS mapset" % (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, )) if not 'gage_lat_wgs84' in studyArea: sys.exit( "Metadata in project directory %s does not contain gage latitude" % (context.projectDir, )) if not 'gage_lon_wgs84' in studyArea: sys.exit( "Metadata in project directory %s does not contain gage longitude" % (context.projectDir, )) grassMetadata = RHESSysMetadata.readGRASSEntries(context) if not 'dem_rast' in grassMetadata: