Creating stream network files for input into DHSVM

/**** Start arc/info

plane% setup owclient arcinfo
plane% arc
arc: &workspace /nfs/meter/usr1/lxb/arcinfo/data

/**** Import ascii dem file to grid:

Add arc/info header to ascii dem file:
ncols 110
nrows 115
xllcorner 546700
y11corner 5173900
cellsize 30
nodata_value 0

arc: &station 9999

usage: ASCIIGRID <in_ascii_file> <out_grid> {INT|FLOAT}
arc: asciigrid dem_filename dem01 INT

/**** Define projection

arc: projectdefine GRID dem01
project: projection utm 
project: units meters
project: zone 10
project: xshift 0
project: yshift 0
project: parameters
project: end
arc: describe dem01

/**** Display grid

arc: grid
grid: shadeset rainbow
grid: mapextent dem01
grid: grids dem01 # linear
 
/**** Find stream network (in grid)

grid: flowdirgrid = FLOWDIRECTION(dem01) 
grid: sinkgrid = SINK(flowdirgrid)

/**** Display sinks

grid: grids sinkgrid
grid: FILL dem01 filleddem

(check for sinks again and iterate until no more sinks)

grid: flowaccgrid = FLOWACCUMULATION(flowdirgrid)
grid: streamnetgrid = con(flowaccgrid > #, 1)
(Where # is the number of contributing cells to use as a threshold.)

grid: str01 = streamline(streamnetgrid, flowdirgrid)
  
/**** Display stream network

grid: linecolor blue
grid: arcs str01
grid: quit

/**** Edit and correct errors in stream network

arc: arctools
select <Edit Tools>
select <File> <Coverage - Open>
select the file with the stream network created in grid (str01)

The stream network will show up in ARCEDIT window.  

To change what and how things are displayed:
select <Display> <Draw env - General>
Note: a useful feature is the display of node errors.  A box indicates a dangled
node (attached to one end of an arc only), a diamond indicates a pseudo-node
(attached to two arcs only).  For stream networks, boxes should only occur at
the headwaters, and you should not have pseudo-nodes (where two streams join,
three arcs meet!).

Now you can perform a number of edits.  However, you will first have to
select the objects you want to operate on:

Select - Click arrow icon in Feature Selection window.  You can select
         more than one object at a time.  After selecting, press 9 to perform 
	 some operation on the selected items.

After editing your stream network:

Save it and exit arctools
<ArcTools> <Quit>

In Arc: Build

arc: BUILD str01 LINE
arc: INTERSECTERR str01
(you should have 0 intersections.  If you have more go back to ArcEdit and
FIX IT)

Regardless:
Go back to ArcEdit and check for node errors.
If there are any fix and iterate over the last few steps till there are no
errors left.  Then return to the Arc prompt.
 
/**** Add class category to stream network:

usage:  ADDITEM <in_info_file> <out_info_file> <item_name> <item_width>
		<output_width> <item_type> {decimal_places} {start_item}

arc: additem str01.aat str01.aat CLASS 1 1 i
(aat - arc attribute table, an ASCII file you can look at)

/**** Interactively assign stream class:

arc: arctools

select edit tools; open coverage str01, select arcs and edit attribute table.
Groups of arcs can be done together using the calculate command.


/**** Run first three scripts

arc: &run roadelevation str01 dem01

/* make copy in case future edits are necessary

arc: copy str01 str02  

arc: &run roadslope str01
arc: &run roaddivide str01
arc: list str01.div

/**** If there are any points listed, you have sinks in the network which 
must be filled.  Perform the following steps only if you have sinks.

write down ELEVATION# of sinks
arc: arctools
edit tools
file -> open table: str02.elev
list, find elevations to change based on elevation#
edit, jump to based on id#
arcedit -> quit -> quit

arc: &run roadslope str02
arc: &run roaddivide str02
arc: list str02.div

/**  OR, edit slopes directly after these steps.  Do not run roadslope after
editing slopes or they will be overwritten.

/**** Repeat editing if still have sinks, if not continue:

arc: copy str02 str03
arc: additem str03.aat str03.aat TYPE 1 1 c

/**** Plot channel drainage direction to check connectivity:

arc: &run roaddirection str03 direction
arc: arcplot
arcplot: linesize 0.0
arcplot: linecolor blue
arcplot: linepattern 0
arcplot: lineput 1
arcplot: linesymbol 1
arcplot: arcs str03
arcplot: arrowsize 0.07
arcplot: arrowtype double solid
arcplot: arcarrows direction sign

/**** Create network input file

arc: &run roadorder str03
arc: &run roadnetwork str03 str_net.dat class

/**** Create row/column map

arc: grid
usage: wshdslope <dem> <slope> <aspect>
grid: &run wshdslope filleddem slope01 aspect01
grid: q
arc: &run rowcolmap aspect01 slope01 rowcol01

/**** Create channel map input file

arc: &run roadmap str03 rowcol01 strmap01

/**** Create stream class look-up table:

arc: arcedit
arcedit: create streams.dat info
	 class	1, 1, i
	 width  4, 4, f, 2
	 depth  4, 4, f, 2
	 roughness  4, 4, f, 2
	 <return>
arcedit: q
arc: info
enter user name> arc
enter command> select streams.dat 
enter command> add from /nfs/meter/usr1/lxb/arcinfo/test/st_class.txt

/** Note: Must use complete address with add from command.

enter command> q stop

Example st_class.txt:


1, .4, .15, .04 
2, 1.0, .35, .04 
3, 2.5, .5, .04 
4, 3.5, 1., .04 
5, 5.5, 2.5, .04 

(Columns correspond to: stream class, channel width, channel depth, channel
roughness (manning's))

info: q stop

arc: relate add; st_class; streams.dat; info; class; class; ordered; rw;;


/**** Create stream map output file:

arc: &run roadmapfile strmap01 str02 str_map.dat st_class//width 
     st_class//depth 0.0
