def arg_parse(): """""" parser = argparse.ArgumentParser( description='ET-Demands Zonal Stats', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( '--gis', nargs='?', default=os.path.join(os.getcwd(), 'gis'), type=lambda x: util.is_valid_directory(parser, x), help='GIS workspace/folder', metavar='FOLDER') parser.add_argument( '--zone', default='huc8', metavar='', type=str, choices=('huc8', 'huc10', 'county','gridmet'), help='Zone type [{}]'.format(', '.join(['huc8', 'huc10', 'county','gridmet']))) parser.add_argument( '-y', '--year', metavar='YEAR', required=True, type=int, help='CDL year') parser.add_argument( '--soil', metavar='FOLDER', nargs='?', default=os.path.join(os.getcwd(), 'gis', 'soils'), type=lambda x: util.is_valid_directory(parser, x), help='Common soil workspace/folder') parser.add_argument( '-o', '--overwrite', default=None, action='store_true', help='Overwrite existing file') parser.add_argument( '--clean', default=None, action='store_true', help='Remove temporary datasets') parser.add_argument( '--debug', default=logging.INFO, const=logging.DEBUG, help='Debug level logging', action="store_const", dest="loglevel") # parser.add_argument( # '--station', nargs='?', required=True, # =lambda x: util.is_valid_file(parser, x), # ='Weather station shapefile', metavar='FILE') # parser.add_argument( # '--gdb', default=None, action='store_true', # ='Write ETCells to a geodatabase') args = parser.parse_args() # Convert relative paths to absolute paths if args.gis and os.path.isdir(os.path.abspath(args.gis)): args.gis = os.path.abspath(args.gis) # if args.station and os.path.isfile(os.path.abspath(args.station)): # .station = os.path.abspath(args.station) if args.soil and os.path.isdir(os.path.abspath(args.soil)): args.soil = os.path.abspath(args.soil) return args
def arg_parse(): """""" parser = argparse.ArgumentParser( description='Build Ag Dem Rasters', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--gis', nargs='?', default=os.path.join(os.getcwd(), 'gis'), type=lambda x: util.is_valid_directory(parser, x), help='GIS workspace/folder', metavar='FOLDER') parser.add_argument('-y', '--years', metavar='YEAR', required=True, help='CDL years, comma separate list and/or range') parser.add_argument('-bs', '--blocksize', default=16384, type=int, metavar='N', help='Block size') parser.add_argument('--mask', default=None, action='store_true', help='Mask pixels outside extent shapefile') parser.add_argument('-o', '--overwrite', default=None, action='store_true', help='Overwrite existing file') parser.add_argument('--pyramids', default=None, action='store_true', help='Build pyramids') parser.add_argument('--stats', default=None, action='store_true', help='Build statistics') parser.add_argument('--debug', default=logging.INFO, const=logging.DEBUG, help='Debug level logging', action="store_const", dest="loglevel") args = parser.parse_args() # Convert input file to an absolute path if args.gis and os.path.isdir(os.path.abspath(args.gis)): args.gis = os.path.abspath(args.gis) return args
def arg_parse(): """""" parser = argparse.ArgumentParser( description='Rasterize Soil Polygons', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( '--gis', nargs='?', default=os.path.join(os.getcwd(), 'gis'), type=lambda x: util.is_valid_directory(parser, x), help='GIS workspace/folder', metavar='FOLDER') parser.add_argument( '--soil', required=True, metavar='FOLDER', type=lambda x: util.is_valid_directory(parser, x), help='Common soil workspace/folder') parser.add_argument( '-o', '--overwrite', default=None, action='store_true', help='Force overwrite of existing files') parser.add_argument( '--pyramids', default=None, action='store_true', help='Build pyramids') parser.add_argument( '--stats', default=None, action='store_true', help='Build statistics') parser.add_argument( '--type', default=['all'], nargs='*', metavar='STR', choices=('all', 'awc', 'clay', 'sand'), help="Soil property type ('all', 'awc', 'clay', 'sand')") parser.add_argument( '--debug', default=logging.INFO, const=logging.DEBUG, help='Debug level logging', action="store_const", dest="loglevel") args = parser.parse_args() # Convert relative paths to absolute paths if args.gis and os.path.isdir(os.path.abspath(args.gis)): args.gis = os.path.abspath(args.gis) if args.soil and os.path.isdir(os.path.abspath(args.soil)): args.soil = os.path.abspath(args.soil) return args
def arg_parse(): """""" parser = argparse.ArgumentParser( description='Download NED tiles', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--gis', nargs='?', default=os.path.join(os.getcwd(), 'gis'), type=lambda x: util.is_valid_directory(parser, x), help='GIS workspace/folder', metavar='FOLDER') parser.add_argument('--tiles', metavar='FOLDER', required=True, help='Coommon DEM tiles workspace/folder') parser.add_argument('-cs', '--cellsize', default=30, metavar='INT', type=int, choices=(10, 30), help='DEM cellsize (10 or 30m)') parser.add_argument('--mask', default=None, action='store_true', help='Download tiles intersecting zones mask') parser.add_argument('-o', '--overwrite', default=None, action="store_true", help='Force overwrite of existing files') parser.add_argument('--debug', default=logging.INFO, const=logging.DEBUG, help='Debug level logging', action="store_const", dest="loglevel") args = parser.parse_args() # Convert relative paths to absolute paths if args.gis and os.path.isdir(os.path.abspath(args.gis)): args.gis = os.path.abspath(args.gis) if args.tiles and os.path.isdir(os.path.abspath(args.tiles)): args.tiles = os.path.abspath(args.tiles) return args
def arg_parse(): """""" parser = argparse.ArgumentParser( description='Build Study Area Raster', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--gis', nargs='?', default=os.path.join(os.getcwd(), 'gis'), type=lambda x: util.is_valid_directory(parser, x), help='GIS workspace/folder', metavar='FOLDER') parser.add_argument('--cdl', metavar='FOLDER', required=True, type=lambda x: util.is_valid_directory(parser, x), help='Common CDL workspace/folder') parser.add_argument('-y', '--years', metavar='YEAR', required=True, help='CDL Year') parser.add_argument('-shp', '--shapefile', required=True, metavar='FILE', help='Study area shapefile') parser.add_argument('--buffer', default=None, metavar='FLOAT', type=float, help='Study area buffer') parser.add_argument('-o', '--overwrite', default=None, action='store_true', help='Overwrite existing files') parser.add_argument('--pyramids', default=None, action='store_true', help='Build pyramids') parser.add_argument('--stats', default=None, action='store_true', help='Build statistics') parser.add_argument('--debug', default=logging.INFO, const=logging.DEBUG, help='Debug level logging', action="store_const", dest="loglevel") args = parser.parse_args() # Convert relative paths to absolute paths if args.gis and os.path.isdir(os.path.abspath(args.gis)): args.gis = os.path.abspath(args.gis) if args.cdl and os.path.isfile(os.path.abspath(args.cdl)): args.cdl = os.path.abspath(args.cdl) if args.shapefile and os.path.isfile(os.path.abspath(args.shapefile)): args.shapefile = os.path.abspath(args.shapefile) return args