/*bevans_road.aml /*This aml calculates flow lengths to the nearest stream channel and average flow length in the watershed contributing to each stream reach for three levels of road density. /*created by Beth Evans, March 8th, 1999 /*----------------------------------------------------------------------------------------- /*Calls Grids: digital elevation model grid in feet(dem), /* stream network grid (streamgrid), /* transportation system grid (roadgrid) /*Returns Grids: flowlength, flowlength1, streamlength, streamlength1, flowchange1, streamchange1 /*---------------------------------------------------------------------------------------- /* fill dem and create flowdirection grid and unweighted flowaccumulation grid &if [exists filldem -grid] &then kill filldem &if [exists flowdir -grid] &then kill flowdir &if [exists flowacc -grid] &then kill flowacc fill dem filldem # # flowdir flowacc = flowaccumulation(flowdir) /* /*create flowlength grid of downslope distance to nearest stream channel &if [exists flowlength -grid] &then kill flowlength flowlength = flowlength(setnull(con(isnull(streamgrid),0,1) == 1,flowdir),#,downstream) /* /*create streamlength grid of average flow length contributing to each streamcell &if [exists acc_length -grid] &then kill acc_length &if [exists avglength -grid] &then kill avglength &if [exists streamlength -grid] &then kill streamlength acc_length = flowaccumulation(flowdir,flowlength) avglength = acc_length div con(flowacc > 0,flowacc,1) streamlength = con(streamgrid,avglength) /* /*identify stream crossings &if [exists streamcross -grid] &then kill streamcross streamcross = streamgrid * roadgrid /* /*select roads within 200 feet of crossings and add to stream grid &if [exists cross200 -grid] &then kill cross200 &if [exists road200 -grid] &then kill road200 &if [exists streamroad -grid] &then kill streamroad &if [exists streamroad1 -grid] &then kill streamroad1 cross200 = eucdistance(streamcross,#,#,200) road200 = con(cross200,1) * roadgrid streamroad = isnull(road200) * isnull(streamgrid) streamroad1 = setnull(streamroad == 0,1) /* /*recalculate flowlengths &if [exists flowlength1 -grid] &then kill flowlength1 flowlength1 = flowlength(flowdir * streamroad1,#,downstream) /* /* subtract the new flowlength grid from the original to show changes in flowlength due~ to roads &if [exists flowchange1 -grid] &then kill flowchange1 flowchange1 = flowlength - flowlength1 /* /*recalculate streamlength grid of average flow length contributing to each streamcell &if [exists acc_length1 -grid] &then kill acc_length1 &if [exists avglength1 -grid] &then kill avglength1 &if [exists streamlength1 -grid] &then kill streamlength1 acc_length1 = flowaccumulation(flowdir,flowlength1) avglength1 = acc_length1 div con(flowacc > 0,flowacc,1) streamlength1 = con(streamgrid,avglength1) /* /*subtract the new streamlength grid from the original to show changes in average flow length contributing to each streamcell due to roads &if [exists streamchange1 -grid] &then kill streamchange1 streamchange1 = streamlength - streamlength1