/************************************************************ /* NAME: delin.aml /* BY: Sean Reed /* /* PURPOSE: Delineate drainage network and watersheds using a /* digital elevation model. /* /* INPUTS: delineation threshold and name of filled DEM /* For information on how to obtain and fill a DEM see /* http://www.ce.utexas.edu/prof/maidment/GISHydro/docs/amls/wtrshd.htm /* /* OUTPUTS: stream grid, stream coverage (covstr), and polygon coverage /* (covwsh). /* /* COMMENTS: This script should be executed from within Grid. /* /************************************************************ project grid watergrid gridw_alb alb.prj grid &type [date -time] fill gridw_alb map_fill /* INITIALIZE NAMES OF INPUT GRIDS AND THRESHOLD VALUE &sv fill = map_fill &if [exists fdr -grid] &then kill fdr all &if [exists fac -grid] &then kill fac all &if [exists covstr -cover] &then kill covstr all &if [exists covwsh -cover] &then kill covwsh all fdr = flowdirection(%fill%) fac = flowaccumulation(fdr) /*&sv thrd = [response 'Enter a delineation threshold'] &sv thrd = 10000 &sv covname = covstr &sv wshname = covwsh /* ELIMINATE GRIDS FROM PREVIOUS RUNS &if [exists str -grid] &then kill str all &if [exists lnk -grid] &then kill lnk all &if [exists znv -grid] &then kill znv all &if [exists out -grid] &then kill out all &if [exists wsh -grid] &then kill wsh all /* BEGIN CALCULATIONS /* Identify all cells with a flowaccumulation greater than the threshold value. str = con ( fac gt %thrd%, 1 ) /* Assign a unique value to cells in separate stream reaches. lnk = streamlink ( str, fdr ) /*&if [exists str -grid] &then /* kill str all /* Convert a grid of links into a line coverage. /* Note that the STREAMLINE function should create arcs that are all /*pointing downstream. %covname% = streamline( lnk, fdr, grid-code, # ) /* For zones defined by the link grid, assign the maximum value of /* flowaccumulation /* in that zone to each cell in that zone. znv = zonalmax ( lnk, fac ) /* Identify outlets as cells with the highest flowaccumulation in a /* given stream reach. out = con ( znv == fac, lnk ) &if [exists lnk -grid] &then kill lnk all &if [exists znv -grid] &then kill znv all /* Delineate watersheds wsh = watershed ( fdr, out ) &if [exists out -grid] &then kill out all /* Convert watershed grids to watershed polygons %wshname% = gridpoly ( wsh ) /* Quit grid quit build %wshname% line &if [exists wsh -grid] &then kill wsh all &sys mv arc.aml aarc.aml quit &return /****** END OF DELIND.AML **********************************