Order.aml


This is the file order.aml. It is designed to calculate the ordering sequence for a connected stream system.
ec test2 &label beginning &sv .num1 = 0 &sv howmany = 0 ef node &sv .num2 [show maximum node#] /* Select all the labels and figure out how &label here /* many times you must go through /* the loop to select all the records. ef arc &sv .num1 = %.num1% + 1 /* Set up a counter which will bail &if %.num1% > %.num2% &then &goto test /* you out of the program when it reaches /* beyond the number of records. sel fnode# = %.num1% &sv .num30 = [show number select] /* If the arc attached to the node already &if %.num30% = 0 &then &goto skip /* has been ordered, skip down to the &sv .num31 = [show select 1] /* bottom. This avoids calculating &sv .num32 = [show arc %.num31% item order] /* the order and all the logic statements. &if %.num32% > 0 &then &goto here &label skip sel tnode# = %.num1% /* Select a to-node equal to the counter. &sv .num3 = [show number select] /* If none are selected, then run ord1.aml /* If one is selected, it is a pseudonode, &if %.num3% = 0 &then &run ord1.aml /* and ord2.aml should be run. &if %.num3% = 1 &then &run ord2.aml /* If two or more are selected, then there &if %.num3% = 2 &then &run ord3.aml /* are a slew of possible iterations. &if %.num3% = 3 &then &run ord4.aml /* Ord3 and ord4 are designed for these &goto here &label test &sv howmany = %howmany% + 1 sel order = 0 /* Check to see if there are any unordered &sv .junk [show number select] /* channels: if there are none, then the aml &if %.junk% = 0 &then &stop /* stops. Otherwise, go back up to top. &if %.junk% ne 0 &then &goto beginning &label ender &stop

Ord1.aml

This aml attributes all the first order channels

sel fnode# = %.num1%			/*  In this case, all channels are
calc order = 1				/*  first order.
&return

Ord2.aml

This aml attributes all the pseudonodes according to the upstream arc attribute

sel tnode# = %.num1%
&sv .num4 [show select 1]				/*  Check the order of the contributing channel
&sv .num5 = [show arc %.num4% item order]

	&if %.num5% = 0 &then &return			/*  If the contributing stream has no order 
							/*  assignation, return to the program

sel fnode# = %.num1%					/*  Otherwise calc the order of the downstream 
 calc order = %.num5%					/*  section equal to the value of the upstream section.

&return


Ord3.aml

This aml is called when two arcs flow into one node

&sv .num6 [show select 1]
&sv .num8 [show arc %.num6% item order]				/*  First set up the global variables 
&sv .num7 [show select 2]					/*  equal to the order of incoming streams
&sv .num9 [show arc %.num7% item order]

        &if %.num8% = 0 &then &return				/*  If either of the streams is unlabeled, 
	&if %.num9% = 0 &then &return				/*  return to the main program.

	&if %.num8% > %.num9% &then &sv .num10 = %.num8%	/*  If one of the incoming streams has a higher value
	&if %.num9% > %.num8% &then &sv .num10 = %.num9%	/*  use that value for the downstream channel.


	&if %.num8% = %.num9% &then &sv .num10 = %.num8% + 1	/*  If they have the same value, use that value + 1

sel fnode# = %.num1%		
calc order = %.num10%						
&return								


Ord4.aml

This is the program ord4.aml - it is designed to handle the occurence of three streams confluencing at the same place.

&sv .num11 [show select 1]
&sv .num12 [show arc %.num11% item order]			/*  Set up some global variable equal to the order 
&sv .num13 [show select 2]					/*  values of the three incoming streams.
&sv .num14 [show arc %.num13% item order]
&sv .num15 [show select 3]
&sv .num16 [show arc %.num15% item order]


		&if %.num12% = 0 &then &return			/*  Return to the main program if any of the 
		&if %.num14% = 0 &then &return			/*  incoming streams are unlabeled.
		&if %.num16% = 0 &then &return

&if %.num12% > %.num14% and %.num12% > %.num16% &then &sv .num17 = %.num12%   /* if all the values for incoming streams 
&if %.num14% > %.num12% and %.num14% > %.num16% &then &sv .num17 = %.num14%   /*  are labeled, then they are checked to
&if %.num16% > %.num14% and %.num16% > %.num12% &then &sv .num17 = %.num16%   /*  determine if they are all different; if
									      /*  so, set order (.num17) = greatest value


&if %.num12% = %.num14% and %.num12% = %.num16% &then &sv .num17 = %.num12% + 1 /*  If they are all the same order, then
										/*  new order = order + 1


&if %.num12% > %.num14% and %.num14% = %.num16% &then &sv .num17 = %.num12%  /*  If 2 are the same, but 3rd is higher, then
&if %.num14% > %.num12% and %.num12% = %.num16% &then &sv .num17 = %.num14%  /*  set the new order = highest of the 3
&if %.num16% > %.num12% and %.num12% = %.num14% &then &sv .num17 = %.num16%


&if %.num12% < %.num14% and %.num14% = %.num16% &then &sv .num17 = %.num14% + 1 /*  If 2 are same, but 3rd is lower, then
&if %.num14% < %.num12% and %.num12% = %.num16% &then &sv .num17 = %.num12% + 1 /*  set order = value of 2 + 1
&if %.num16% < %.num12% and %.num12% = %.num14% &then &sv .num17 = %.num12% + 1


sel fnode# = %.num1%						/*  Now select the fnode needed and calc its order
  calc order = %.num17%

&return


Watershed.aml

This is an aml for creating watersheds for contributing areas to points inputted by the user. A DEM is required, as is a flowdirection map, and a stream map is useful for helping discern the bottomland areas.

mapex DEM
markerset municipal
markersym 201						/*  First, show the area & have user zoom in.
markersize .05
points done_samp
textset plotter 
textsym 97
textsize .3
text 'Zoom in on the desired area'
mapex *

clear
linecolor 1
arcs wagu

linesym 4						/*  Then show the stream network
arcs strmcopy2

markersize .15						/*  Then show the points of interest
points done_samp

text 'Zoom in again'
mapex *
clear

gridshades nofill10
linecolor 1
arcs wagu						/*  Zoom in again
linecolor 4
arcs strmcopy2
markersize .2
points done_samp

text 'Check to see the value of the target cell'	/*  Query what the point's target value is,
cellvalue samp_grid *					/*  which will serve as basis for map name

&sv .mapname = [response 'Enter the mapname (in CAPS)'] /*  Ask user for the map name

%.mapname% = watershed (noflow10, selectpoint (nofill10, *))  /*  Run the watershed routine interactively

gridshades %.mapname%					/*  Show the resultant map to the user
points done_samp

linecolor 1
arcs wagu
&sv okay = [response ' Does this look OK? y/n']		/*  If the map is OK, then go on to extract info
&if %okay% = n &then &r subws1.aml			/*  If map is incorrect, delete it & start over
&if %okay% = y &then &run zonal.aml

&r subws2.aml


Subws1.aml


This AML kills off coverages that were improperly made by the watershed AML
kill %.mapname% all &r subws2.aml


Subws2.aml


This small AML simply asks the user whether the watershed.aml routine should be called again or not
clear &sv again = [response 'Do you want to run this again? y/n'] &if %again% = y &then &r wshed.aml &if %again% <> y &then quit


Zonal.aml


This AML is run from ARC; it sets up the name of the output files that will store data, opens up INFO, and outputs information from INFO data tables into the flet files.
%.mapname%.stat = zonalstats (%.mapname%, DEM, all) /* First set up some filenames %.mapname%.geo = zonalgeometry (%.mapname%, all) &sys echo %.mapname% >> watershed.geo /* Echo the coverage name to the output files &sys echo %.mapname% >> watershed.stats /* to identify the information &data ARC INFO ARC SELECT %.mapname%.STAT OUTPUT ../watershed.stats DISPLAY MEAN,MIN,MAX,STD PRINT /* Output the relevant information into OUTPUT arcsnp /* text files. SELECT %.mapname%.GEO OUTPUT ../watershed.geo DISPLAY AREA,PERIMETER,THICKNESS,XCENTROID,YCENTROID,MAJORAXIS,MINORAXIS,ORIENTATION PRINT OUTPUT arcsnp Q STOP &end

Other AML extraction routines

AMLs similar in structure were completed to extract perinent information, including elevation changes, channel density, and flowlength characteristics. All were based on those maps created from the watershed.aml file shown above.