91ÁÔÆæ

Flow Direction Arrows

Abstract:

This project was developed in Python and put into an Arcpy Tool Box to be used with Arc GIS Pro Desktop as a user based visual enhancements for a Flow Direction Raster (FDIR). FDIRs are derived from Digital Elevation Model (DEM) and are commonly used for stream and channel network delineation according to Tarboton (1997). The tool box developed in this project is named FDIR_Arrows.pyt, and it also has an attached module utils.py, that carries the necessary functions for it to work.

This tool box also calls the math, arcpy, and the NumPy modules as well. It takes the colorful FDIR and converts the orientation values for each cell into a polyline that is centered in the middle of each cell. The length of this polyline is dynamic such that it is 0.0325% shorter than the distance that it spans. In the case of horizontal and vertical directions it will be 0.0325% shorter than the cell width and or height, and the same holds true if the flow direction is diagonal, it will be that much shorter than the diagonal length of the cell. This allows for the optimal distance from the edges of the cell for minimal overlap. The symbology will need to be changed from the output polyline to any arrow of choice so that the flow direction can be determined. Due to the cell by cell processing nature of this tool it is advised to ether use a small study area or resample the study area to a larger cell size to diminish processing time and so that the flow direction arrows can be visible.

Authored by

Timothy Davis and Huidae Cho

 

picture of flow direction arrow presentation

Background:

With the improvement of hydraulic tools in Arcpy and the wider spread use of them as well, this tool will become very useful. The purpose of this tool is to take a Flow Direction Raster that was created using Arc products and make them more visually accessible to the user. To understand how it works we need to first understand what a flow direction raster is and where it comes from, and then how this tool reads it and what it does in the end with it.

The DEM is one of the most important data sets that represents earth’s surface and is useful for any form or type of hydraulic analysis, and it is becoming more widely used in a variety of other areas as well as noted by Jenson (1991). One of the most common uses is fining stream networks and there are many ways and different models that have been used for this but as Montgomery, and Foufoula-Georgiou (1993) points out very little effort has apparently been put into ground truthing the results. That said though, for this project we are more concerned about accuracy than precision because repeatability is our moto for now.

Objectives:

 This project was developed as a final project for the under-graduate course of GISC – 4500K (Application Development) in the Institute of Environmental Spatial Analysis at The University of North Georgia. The resulting tool from this project is intended to be used as an add for better visual analysis of any given FDIR raster. This tool is essentially a Python script inside an Arcpy Tool Box shell that operates in the Arc GIS Pro Desktop GUI interface.

 

Methods

This tool is divided into two parts and it also requires an import of the math, the arcpy, and the NumPy modules for it to function properly. The first part is the main arcpy tool box shell with all the built-in options for various types of tools and operations. It is in this part that I have scripts like the arcpy Create Feature class management, and for geometry in this script we set it equal to POLYLINE. This first half also takes the spatial Reference and applies it to the feature class so that it can be located with reference system. For iterating through the cells one at a time I used the arcpy da Insert Cursor in a “with” statement so that as the code is read row and column the 2-dimensional location is preserved. This part is the interface side of the tool and it takes as input a flow directional raster, a file path, and a name for the new feature class that is created. It is also where I have all the class functions, the first one being the Toolbox and the second being the actual Flow Direction Arrows tool.

The second half of this tool is the actual functions that do the work. So first I define a function that gets the raster coordinates so that the new feature class that will be created has a coordinate attached to each one at the center of the cell and at the center of each line. This coordinate is determined by taking the extent of the raster at the  Min X  plus the width and times the column plus width divided by two, and the Max Y minus the height times the row minus the height divided by two. The dividing by two is to get the center of the cell. The second definition query is the one that draws the line. This one is comprised of an “if” statement and seven “elif” statements that determine the angle of the line depending on which of the base two numbers that are assigned to that cell. Then there is one more “if” statement that determines the length of the line based on whether it is vertical, horizontal, or diagonal. And for each line I divide the total length by 3.25 to keep the ends inside the cell for tidy reasons.

Results:

As stated earlier, there is a need for an optimal cell size with the placement of arrows in each cell. This in part is because as shown is Figure 2, the arrows are so small that it almost impossible to determine which way they are pointing and if you are trying to cover a large area it will take a considerable amount of time to run this tool. Even though Arc Pro Desktop has a dynamic zoom and the arrows will enlarge as you zoom in, you are still left with viewing a smaller area and zooming in and out can also be annoying because of the time Arc Pro Desktop takes to draw all the arrows.

Resampling the cell size was the best fix I found, and one size might work better in one place and not so much in another. In areas that were very busy and had lots of abrupt elevation changes, it was found to be easier to understand with a larger cell size as shone in Figure 4, and the same is true that if the area does not have much varying elevation that it is possible to use a smaller cell size and still be able to understand the flow direction on the raster tile as shone in Figure 3.

Resampling the cell size is easily done with the resample tool in Arc Pro Desktop and can be applied to the DEM elevation raster prior to creating the flow direction raster to save on processing time. It would be possible to include resampling in this tool, but if the user is simply trying to find the optimal cell size it would be better to do the resampling alone and not clutter the users folder with overwrites of unused data and it would save on processing time as well. There is however something to be said about loss of data, when the user resamples a raster there is inevitably a loss of the original data in the raster. This can be undone by resampling to a smaller cell again, but that is not advised as it will essentially be guessing at what the cells should be. If there is a need to down size, the best way to do it is to start over with the original raster and that way you will have all the original data included.

Conclusion:

So, in conclusion this tool worked very well, and it was almost exactly what we had originally purposed. In the future it would be of interest to perhaps add the code that would draw the arrow instead of just an oriented line. This would require so more advanced codding and possible something that may involve using another programming language as well. That said I was very pleased to be able to build this tool and I hope to continue to improve my coding skills to be able to use them in the work force in the future.