r.fill.dir(1)	       Grass User's Manual	    r.fill.dir(1)



NNAAMMEE
       rr..ffiillll..ddiirr   - Filters and generates a depressionless ele-
       vation map and a flow direction map from a given elevation
       layer
       _(_G_R_A_S_S _R_a_s_t_e_r _P_r_o_g_r_a_m_)

SSYYNNOOPPSSIISS
       rr..ffiillll..ddiirr


	rr..ffiillll..ddiirr [[--ff]] iinnppuutt==_n_a_m_e eelleevvaattiioonn==_n_a_m_e
	      ddiirreeccttiioonn==_n_a_m_e [aarreeaass==_n_a_m_e] [ttyyppee==_n_a_m_e]

OOPPTTIIOONNSS
   FFllaaggss::
       --ff     find  unresolved	areas only (don't generate filled
	      DEM except 1 pixel sinks)


   PPaarraammeetteerrss::
       iinnppuutt==_n_a_m_e
	      elevation map

       eelleevvaattiioonn==_n_a_m_e
	      corrected elevation map (depression less)

       ddiirreeccttiioonn==_n_a_m_e
	      flow direction map

       ttyyppee==_n_a_m_e
	      type of flow direction map to be created

       aarreeaass==_n_a_m_e
	      Output raster map of problem areas


EEXXAAMMPPLLEE
       rr..ffiillll..ddiirr iinnppuutt==_a_n_s_i_._e_l_e_v eelleevvaattiioonn==_a_n_s_i_._f_i_l_l_._e_l_e_v ddiirreecc--
       ttiioonn==_a_n_s_i_._a_s_p



       will  create  a	depressionless	(sinkless)  elevation map
       ansi.fill.elev and a flow direction map ansi.asp  for  the
       type "grass".


AATTTTEENNTTIIOONN
       _T_h_e _t_y_p_e is the type of format at which the user wishes to
       create the flow direction map. The _a_g_n_p_s format gives cat-
       egory  values from 1-8, with 1 facing north and increasing
       values in the clockwise	direction.   The  _a_n_s_w_e_r_s  format
       gives  category	values	from  0-360 degrees, with 0 (360)
       facing east and values increasing in the counter clockwise
       direction  at 45 degree increments. The _g_r_a_s_s format gives
       the same category values as the _r_._s_l_o_p_e_._a_s_p_e_c_t program.


       _T_h_e _m_e_t_h_o_d adopted to filter the elevation map and rectify
       it is based on the paper titled "Software Tools to Extract
       Structure  from	Digital  Elevation  Data  for  Geographic
       Information  System  Analysis"  by  S.K.  Jenson  and J.O.
       Domingue (1988).


       The procedure takes an elevation layer as input	and  ini-
       tially  fills all the depressions with one pass across the
       layer. Next the flow direction algorithm tries to  find	a
       unique  direction  for each cell. If the watershed program
       detects areas with pothholes, it delineates this area from
       the  rest  of  the area and once again the depressions are
       filled using the neighborhood technique used by	the  flow
       direction  routine. The final output will be a depression-
       less elevation layer and a unique flow direction layer.


       This (D8) flow algorithm  performs  as  follows:  At  each
       raster cell the code determines the slope to each of the 8
       surrounding cells and assigns the flow  direction  to  the
       highest	slope out of the cell.	If there is more than one
       equal, non-zero slope then the code  picks  one	direction
       based on preferences that are hard-coded into the program.
       If the highest slope is flat and in more than  one  direc-
       tion  then  the	code first tries to select an alternative
       based on flow directions in the adjacent cells.	It itera-
       tives  that  process,  effectively propagating flow direc-
       tions from areas where the directions are known	into  the
       area where the flow direction can't otherwise be resolved.


       The flow direction map can be encoded  in  either  ANSWERS
       (Beasley  et.al,  1982) or AGNPS (Young et.al, 1985) form,
       so that it can be readily used as input	to  these  hydro-
       logic models. The resulting depressionless elevation layer
       can further be manipulated for deriving slopes  and  other
       attributes required by the hydrologic models.


       In  case  of  local  problems, those unfilled areas can be
       stored optionally.  Each unfilled area  in  this  maps  is
       numbered. The flag _"_-_f_" instructs the program to fill sin-
       gle-cell pits but otherwise to  just  find  the	undrained
       areas  and exit. With the _"_-_f_" flag set the program writes
       an elevation map with  just  single-cell  pits  filled,	a
       direction  map  with  unresolved problems and a map of the
       undrained areas that  were  found  but  not  filled.  This
       option was included because filling DEMs was often not the
       best way to solve a drainage problem.  These  options  let
       the user get a partially-fixed elevation map, identify the
       remaining problems and fix the problems appropriately.

NNOOTTEE
       _T_h_e _r_._f_i_l_l_._d_i_r program is sensitive to the ccuurrrreenntt  wwiinnddooww
       sseettttiinngg.  Thus  the program can be used to generate a flow
       direction map for any sub-area within the full map  layer.
       Also, _r_._f_i_l_l_._d_i_r is sensitive to any _m_a_s_k in effect.


       In  some  cases	it  may  be  necessary	to run r.fill.dir
       repeatedly (using output from one run as input to the next
       run) before all of problem areas are filled.

SSEEEE AALLSSOO
       _r_._d_i_r_e_c_t_, _r_._f_i_l_l_n_u_l_l_s_, _r_._s_l_o_p_e_._a_s_p_e_c_t


       Jenson,	S.K.,  and  J.O. Domingue. 1988. Extracting topo-
       graphic structure from digital elevation  model	data  for
       geographic  information	system analysis. Photogram. Engr.
       and Remote Sens. 54: 1593-1600.


       Beasley, D.B. and L.F. Huggins. 1982. ANSWERS (areal  non-
       point source watershed environmental response simulation):
       User's manual. U.S. EPA-905/9-82-001, Chicago, IL, 54 p.


       Young, R.A., C.A. Onstad, D.D. Bosch  and  W.P.	Anderson.
       1985.   Agricultural  nonpoint  surface	pollution  models
       (AGNPS) I and II model documentation. St. Paul: Minn. Pol-
       lution  control	Agency and Washington D.C., USDA-Agricul-
       tural Research Service.

AAUUTTHHOORR
       Fortran version: Raghavan Srinivasan,  Agricultural  Engi-
       neering Department, Purdue University

       Rewrite to C with enhancements: Roger S. Miller

       _L_a_s_t _c_h_a_n_g_e_d_: _$_D_a_t_e_: _2_0_0_2_/_0_1_/_2_5 _0_5_:_4_5_:_3_4 _$



GRASS 5.0					    r.fill.dir(1)
