/* AML NAME: soils.aml (Run from the "arc" prompt.)
/* FUNCTION: Creates a coverage of soil types within a specified
/* watershed and attaches attributes from mapunit info files to that
/* coverage. Also appends cumulative soil group type percentages (A%, B%,
/* C%, D%) to the attached attributes.
/* statsgo - a polygon coverage of soil types within a particular state or
/* region
/* mapunit - statsgo info table that includes mapunit attributes
/* comp - statsgo info table that includes component attributes
/* covname - polygon coverage of the specified watershed
/* clip selects the polygons from statsgo that are within the boundary of
/* covname and creates a new coverage of them called soilshed
clip statsgo covname soilshed
/* A method of determining the percentages of soil group types A, B, C, & D
/* that occur within a mapunit follows. This is done via a "0ne-to-many"
/* relate between the mapunit and comp tables.
/* the following 4 commands create items A%, B%, C%, D% within the mapunit
/* table. As specified, the items are 3 characters wide for both field
/* width and output width, and are integer values.
additem mapunit A_pct 3 3 i
additem mapunit B_pct 3 3 i
additem mapunit C_pct 3 3 i
additem mapunit D_pct 3 3 i

/* the next set of commands performs a relate between the mapunit and comp
/* tables:
select comp /* selects the comp table
relate add /* identifies that items will be added to comp via relate
mu mapunit /* mu is a temporary abbreviation for mapunit
info /* identifies the type of data being manipulated
muid /* defines the "relate item"
muid /* defines table location where new items will be added
ordered /* ordered relate type
rw /* read/write access
/* the following set of commands determine the total A%, B%, C%,and D% for
/* a mapunit by respectively reselecting the "comp" records with
/* specific values for the hydgrp field, summing the values of the comppct
/* fields for those records, and dynamically storing the result in the
/* mapunit items A%, B%, C%, and D%. This process is repeated for each
/* value of hydgrp.
reselect hydgrp = 'A'
calc mu//A_pct = mu//A_pct + comppct
select comp
reselect hydgrp = 'B'
calc mu//B_pct = mu//B_pct + comppct
select comp
reselect hydgrp = 'C'
calc mu//C_pct = mu//C_pct + comppct
select comp
reselect hydgrp = 'D'
calc mu//D_pct = mu//D_pct + comppct

/* All of the attributes of mapunit, including the newly determined A%, B%,
/* C%, and D%, are then added to the soilshed polygon attribute table
/* through use of the joinitem command. The relate item muid (mapunit id)
/* is used to associate the two tables. The data from mapunit is enterred
/* into soilshed.pat immediately following the item muid.
joinitem soilshed.pat mapunit soilshed.pat muid muid
/* In the event that the watershed coverage includes boundaries of
/* subwatersheds, the statsgo polygons may also be desired on a subwatershed
/* basis. Use of the intersect command creates a new coverage (soilstat)
/* that defines soil type data within subwatershed boundaries:
intersect soilshed covname soilstat

/**********end of AML************************************************

Go to AML Listing