/* /*------------- /*--- AGREE --- /*------------- /* /*--- Creation Information --- /* /*Name: agree.aml /*Version: 1.1 /*Date: 10/13/96 /*Author: Ferdi Hellweger /* Center for Research in Water Resources /* The University of Texas at Austin /* ferdi@crwr.utexas.edu /* /*--- Purpose/Description --- /* /*AGREE is a surface reconditioning system for Digital Elevation Models (DEMs). /*The system adjusts the surface elevation of the DEM to be consistent with a /*vector coverage. The vecor coverage can be a stream or ridge line coverage. /* /*--- Get Input Data --- /* &args oelevgrid vectcov buffer smoothdist sharpdist /* &if ( [ length %oelevgrid% ] = 0 ) &then &do /*-ls001 &type AGREE: &type AGREE: INPUT REQUIRED /* &label a &type AGREE: &sv oelevgrid = [ response 'AGREE: Elevation Grid'] &if ( [ length %oelevgrid% ] = 0 ) &then &do /*-ls002 &type AGREE: &type AGREE: INPUT ERROR - Elevation Grid has to be specified &goto a /*-le002 &end &if ( not [ exists %oelevgrid% -grid ] ) &then &do /*-ls003 &type AGREE: &type AGREE: INPUT ERROR - Grid does not exist &goto a /*-le003 &end /* &label b &type AGREE: &sv vectcov = [ response 'AGREE: Vector Coverage'] &if ( [ length %vectcov% ] = 0 ) &then &do /*-ls004 &type AGREE: &type AGREE: INPUT ERROR - Vector Coverage has to be specified. &goto b /*-le004 &end &if ( not [ exists %vectcov% -cover ] ) &then &do /*-ls006 &type AGREE: &type AGREE: INPUT ERROR - Coverage does not exist &goto b /*-le006 &end /* &label c &type AGREE: &sv buffer = [ response 'AGREE: Buffer Distance'] &if ( [ length %buffer% ] = 0 ) &then &do /*-ls008 &type AGREE: &type AGREE: INPUT ERROR - Buffer Distance has to be specified &goto c /*-le008 &end /* &type AGREE: &type AGREE: Note that for the upcoming smooth and sharp drop/raise &type AGREE: distance positive is up and negative is down. /* &label d &type AGREE: &sv smoothdist = [ response 'AGREE: Smooth Drop/Raise Distance'] &if ( [ length %smoothdist% ] = 0 ) &then &do /*ls009 &type AGREE: &type AGREE: INPUT ERROR - Smooth Drop/Raise Distance has to be specified &goto d /*-le009 &end /* &label e &type AGREE: &sv sharpdist = [ response 'AGREE: Sharp Drop/Raise Distance'] &if ( [ length %sharpdist% ] = 0 ) &then &do /*-ls010 &type AGREE: &type AGREE: INPUT ERROR - Sharp Drop/Raise Distance has to be specified &goto e /*-le010 &end /*-le001 &end /* &type AGREE: &type AGREE: Starting... /* /*--- General Set Up --- /* &type AGREE: &type AGREE: Extracting original elevation grid parameters... &describe %oelevgrid% &sv cellsize = %GRD$DX% /* &if [extract 1 [show display]] ne 9999 &then display 9999 /* &type AGREE: &type AGREE: Displaying original elevation grid... mape %oelevgrid% gridpaint %oelevgrid% value linear nowrap gray /* /*set analysis environment /* &type AGREE: &type AGREE: Setting the analysis environment... setwindow %oelevgrid% setcell %oelevgrid% /* /*--- Agree Method --- /* /*compute vectgrid /* &type AGREE: &type AGREE: Computing vector grid... &type AGREE: &if [exists vectgrid -grid] &then arc kill vectgrid all vectgrid = linegrid ( %vectcov% ) &type AGREE: &type AGREE: Displaying vector grid... gridpaint vectgrid /* /*compute smogrid /* &type AGREE: &type AGREE: Computing smooth drop/raise grid... &type AGREE: &if [exists smogrid -grid] &then arc kill smogrid all smogrid = int ( setnull ( isnull ( vectgrid ), ( %oelevgrid% + %smoothdist% ) ) ) &type AGREE: &type AGREE: Displaying smooth drop/raise grid... gridpaint smogrid value linear nowrap gray /* /*compute vectdist and vectallo /* &type AGREE: &type AGREE: Computing vector distance grids... &type AGREE: &if [exists vectdist -grid] &then arc kill vectdist all &if [exists vectallo -grid] &then arc kill vectallo all vectdist = eucdistance( smogrid, #, vectallo, #, # ) &type AGREE: &type AGREE: Displaying vector distance grid... gridpaint vectdist value linear nowrap gray /* /*compute bufgrid1 and bufgrid2 /* &type AGREE: &type AGREE: Computing buffer grid... &type AGREE: &if [exists bufgrid1 -grid] &then arc kill bufgrid1 all &if [exists bufgrid2 -grid] &then arc kill bufgrid2 all bufgrid1 = con ( ( vectdist > ( %buffer% - ( %cellsize% / 2 ) ) ), 1, 0) bufgrid2 = int ( setnull ( bufgrid1 == 0, %oelevgrid% ) ) &type AGREE: &type AGREE: Displaying buffer grid... gridpaint bufgrid2 value linear nowrap gray /* /*compute bufdist and bufballo /* &type AGREE: &type AGREE: Computing buffer distance grids... &type AGREE: &if [exists bufdist -grid] &then arc kill bufdist all &if [exists bufallo -grid] &then arc kill bufallo all bufdist = eucdistance( bufgrid2, #, bufallo, #, # ) &type AGREE: &type AGREE: Displaying buffer distance grid... gridpaint bufdist value linear nowrap gray /* /*compute smoelev /* &type AGREE: &type AGREE: Computing smooth modified elevation grid... &type AGREE: &if [exists smoelev -grid] &then arc kill smoelev all smoelev = vectallo + ( ( bufallo - vectallo ) / ( bufdist + vectdist ) ) * vectdist &type AGREE: &type AGREE: Displaying smooth modified elevation grid... &type AGREE: gridpaint smoelev value linear nowrap gray /* /*compute shagrid /* &type AGREE: &type AGREE: Computing sharp drop/raise grid... &type AGREE: &if [exists shagrid -grid] &then arc kill shagrid all shagrid = int ( setnull ( isnull ( vectgrid ), ( smoelev + %sharpdist% ) ) ) &type AGREE: &type AGREE: Displaying sharp drop/raise grid... gridpaint shagrid value linear nowrap gray /* /*compute elevgrid /* &type AGREE: &type AGREE: Computing modified elevation grid... &type AGREE: &if [exists elevgrid -grid] &then arc kill elevgrid all elevgrid = con ( isnull ( vectgrid ), smoelev, shagrid ) &type AGREE: &type AGREE: Displaying modified elevation grid... gridpaint elevgrid value linear nowrap gray /* /*clean up /* &type AGREE: &type AGREE: Cleaning up... &type AGREE: arc kill vectgrid all arc kill smogrid all arc kill vectdist all arc kill vectallo all arc kill bufgrid1 all arc kill bufgrid2 all arc kill bufdist all arc kill bufallo all arc kill smoelev all arc kill shagrid all /* /*close up /* &type AGREE: &type AGREE: Normal end. &type AGREE: &type AGREE: NOTE: Modified elevation grid is saved as elevgrid in current workspace. &type AGREE: &return