def main(): """ RichDEM depression breaching """ # lazy import RICHDEM try: import richdem as rd except: g.message( flags="e", message=("RichDEM not detected. Install pip3 and " + "then type at the command prompt: " + '"pip3 install richdem".'), ) _input = options["input"] _output = options["output"] _topology = options["topology"] dem = garray.array() dem.read(_input, null=np.nan) rd_inout = rd.rdarray(dem, no_data=np.nan) rd.BreachDepressions(dem=rd_inout, in_place=True, topology=_topology) dem[:] = rd_inout[:] dem.write(_output, overwrite=gscript.overwrite())
def BreachDepressions(): parser = argparse.ArgumentParser(formatter_class=RawTextHelpFormatter, description="""RichDEM Depression Breaching""") parser.add_argument('dem', type=str, help='Elevation model') parser.add_argument('outname', type=str, help='Name of output file') parser.add_argument('-v', '--version', action='version', version=rd._RichDEMVersion()) args = parser.parse_args() dem = rd.LoadGDAL(args.dem) rd._AddAnalysis(dem, ' '.join(sys.argv)) rd.BreachDepressions(dem) rd.SaveGDAL(args.outname, dem)
def BreachDepressions(): parser = argparse.ArgumentParser( formatter_class=RawTextHelpFormatter, description="""RichDEM Depression Breaching Modes: Complete: Breach everything. Ignore max_path_len, max_path_depth. There will be no depressions. There will be no mercy. Selective: Only breach those depressions that can be breached using the above criteria. Constrained: Dig as long a path as necessary, but don't dig it deeper than max_path_depth. """) parser.add_argument('dem', type=str, help='Elevation model') parser.add_argument('outname', type=str, help='Name of output file') parser.add_argument('-m', '--mode', required=True, type=str, help='Breaching mode to use') parser.add_argument( '-f', '--fill', action='store_true', help="If depressions can't be breached, should they be filled?") parser.add_argument('-l', '--max_path_len', type=int, help="Maximum length of breaching path in cells") parser.add_argument('-d', '--max_path_depth', type=float, help="Maximum depth of breaching path in z-units") parser.add_argument('-v', '--version', action='version', version=rd._RichDEMVersion()) args = parser.parse_args() dem = rd.LoadGDAL(args.dem) rd._AddAnalysis(dem, ' '.join(sys.argv)) rd.BreachDepressions(dem, mode=args.mode, fill=args.fill, max_path_len=args.max_path_len, max_path_depth=args.max_path_depth, in_place=True) rd.SaveGDAL(args.outname, dem)
def main(): """ RichDEM depression breaching """ options, flags = gscript.parser() _input = options['input'] _output = options['output'] _topology = options['topology'] dem = garray.array() dem.read(_input, null=np.nan) rd_inout = rd.rdarray(dem, no_data=np.nan) rd.BreachDepressions(dem=rd_inout, in_place=True, topology=_topology) dem[:] = rd_inout[:] dem.write(_output, overwrite=gscript.overwrite())