Calculating the volume and surface of a reservoir using ArcGIS

Today we are going to see how to calculate the volume of a projected reservoir which will be created with the construction of the Villafria Dam in Northern Spain using ArcGIS and its extension 3D Analyst.

We start by activating the 3D Analyst Extension: Customize menu > Extensions…

The data required for this exercise is a contour map with lines placed at 5-meter intervals (contours.shp).

The first step is converting the contour map into a Triangulated Irregular Network (TIN):

Open ArcToolbox > 3D Analyst Tools > TIN Management > Create TIN

Select “contours.shp” as the Input Feature Class and name the Output TIN “terrain_tin”:

The process of creating a new TIN may take several minutes, depending on the accuracy of the output surface.

We now have to select the contour that marks the reservoir maximum level, which according to the project is set at 1115 meters above sea level. So, we select the 1115 contour using the Select by Attributes tool: “Selection menu > Select By Attributes…”. In the query builder enter data as shown in the next picture:

Please note that, in order to perform surface and volume calculations, the contour must be closed, so unselect all other contours that are not linked to the actual reservoir surface.

This contour gives us an idea of the maximum flood extent of the reservoir once filled at its full capacity.

The next step is converting the selected contour (Polyline) into a Polygon: ArcToolbox > Data Management Tools > Features > Feature To Polygon.

And finally, to calculate the total volume of the reservoir, we use the tool “Polygon Volume”: ArcToolbox > Terrain and TIN Surface > Polygon Volume.

Select “terrain_tin” as the Input Surface; “1115_contour_polygon” as the Input Feature Class; and Height Field as “CONTOUR”. In “Reference Plane”, make sure that BELOW is selected. The volume and surface area will be calculated below the reference plane height of the polygon. Leave the rest as default:

Click on OK. The calculation process may take several minutes.

As the final result, two new fields are added to the “1115_contour_polygon.shp” attribute table:  “Volume” and “SArea”. In this case, the result is in cubic meters, since we are working in International System of Units (S.I.): 11,834,796.1198 (equivalent to 11.835 cubic hectometers). We also got the total flooded surface: 1110140.5082 square meters (equivalent to 111.014 hectares).


Watershed delineation using ArcGIS Model Builder

In previous posts we took an overview of geoprocessing in ArcGIS and we discussed about delimiting watersheds using the Hydrology tools of the ArcGIS Spatial Analyst toolset. Now we are going to automate this task by using Model Builder.

We will create an automated process to delimitate watersheds from a Digital Elevation Model. In this example, I will be using as an input the same DEM as the Watershed delineation using ArcGIS Hydrology tools.

1.- In the ArcMap 10 Catalog window, we browse to Toolboxes >  My Toolboxes. Right-click on MyToolboxes and select New > Toolbox, to add a new toolbox to which we give the name of ModelWatershed.

Right-click on ModelWatershed toolbox  > New > Model… This prompts the Model Builder window.

2.-  Right-click on the ModelBuilder window > Create Variable… In the list, we select “Raster Layer”. A blank oval is then added to the Model Builder window.

3.- In the Catalog window, we browse to System Toolboxes > Spatial Analyst Tools > Hydrology Drag and drop the “Fill”, “Flow Direction”, “Flow Accumulation”, “Stream Link” and “Watershed” tools to the Model Builder window.

Next, go to System Toolboxes > Data Management tools > Feature and drag “Feature Vertices To Points” tool to the Model Builder window.

Finally, go to System Toolboxes > Spatial Analyst Tools > Map Algebra and drag “Raster Calculator” tool (Map algebra).

4.- In the Model Builder window standard toolbar, select the “Connect” tool and link the previously added tools. The result will look like this:

5.- Right-click on each of the inputs and outputs (blank ovals), select the options “Model Parameter” and ” Add To Display”. The result is shown in the figure below:

As you can see, a “P” appears next to each input and output, indicating that they are “parameters”.

6.- Right-click on “Raster Layer” (the variable we created in step 2), select Open… A window prompts in which we have to select the DEM we want to use as an input. Once selected the input DEM you can see how some of the tools get activated by changing their color as shown below:

7.- Right click on “Raster Calculator”, select Open… A window will appear in which we must specify the minimum size of the cells covering the watershed. In this case we write the following expression: “Con (“%Output accumulation raster%”> 20000, 1)”. In this case, “Output accumulation raster” is the output of the “Flow Accumulation” tool and 20000 is the minimum size in pixels for a given watershed. In this example, the pixel size of the DEM is 5×5 m so the minimum surface of the resulting watersheds will be 100,000 m2 (this procedure avoid the creation of “microbasins”).

The Model Builder window will look like this:

8.- Right click on “Feature Vertices To Points”, select Open… In the field “Point Type (optional)” we specify “END”.

9.- We have to indicate the path in which the outputs will be stored.

Right-click on “Fill” tool, select Properties… In the “Environments” tab, activate “Workspace” and click on “Values…”. We must fill the “Current Workpace” and “Scratch Workspace” with the location of the folder where you want to save the outputs.

10.- Finally, we run our model by clicking on the “Run” tool of the standard toolbar. After a few minutes, this is the final result:

The main advantage of this model is that we can run it as many times as we want using different datasets.

Additionally, Model Builder allows you to export any model to Python code, where you can refine your model by adding advanced conditional and iterative logic. We will see in later posts how to do this.

Watershed delineation using ArcGIS Hydrology tools

The required data for this tutorial is a 5×5 m cell size Digital Elevation Model (DEM) obtained from the National Aerial Orthoimagery Dataset (PNOA). The study area is from a small torrential basin in the central Pyrenees (Aras ravine), well known for a flash flood event that wiped out a campsite on 7th August, 1996 claiming the lives of 87 people.

Digital Elevation Model

First, in the ArcToolbox window expand Spatial Analyst Tools > Hydrology.

Hydrology Tools

1.- Fill sinks in the Digital Elevation Model: We start by removing small  imperfections in the digital  elevation model using the Fill tool. Open the Fill tool. Set the  input surface to the Digital  Elevation Model (DEM) of the  study area.

It is important to build a depressionless DEM for all subsequent hydrological analyses. Areas of internal drainage can cause problems later in the watershed delineation process.

2.- Flow Direction: Direction of flow must be known for each cell, because it is  direction of flow that determines the ultimate destination of water flowing across the surface. The numbers in the Flow Direction layer show flow direction from each cell to its steepest downslope neighbor.

3.- Flow Accumulation: This tool calculates the flow into each cell by accumulating the cells that flow into each downslope cell. In the Flow Accumulation layer each cell contains a value representing the number of cells upstream from that cell. Cells  with higher values will tend to be located in drainage channels rather than on hillsides or ridges.  We will symbolize the flow accumulation layer to make these differences clear.

4.- Create Watershed Pour Points: In ArcCatalog we will create a new empty shapefile to store the new pour point. We delineate the pour point at the watershed outlet using the Editor toolbar. Everything upstream from the pour point will define a single watershed.

5.- Snap Pour Point: We will use the Snap Pour Point tool to ensure your our point is located on the highest flow accumulation cell within a specified radius. We set the snap distance at 100 meters.  The Snap Pour Point tool also converts the pour point into the raster format needed later in the watershed delineation step.

6.- Delineate watershed: In this final step, we select the flow direction grid as the input flow direction raster, and the raster version of the pour point as the input pour point data. Finally, we select an output raster pathname. The new watershed raster will be added to the map.

For area calculations and for later use to clip other datasets, we convert the watershed raster to a polygon using the Conversion Tools of the ArcToolbox (ArcToolbox > Conversion Tools > From Raster > Raster to Polygon).

This is all for now. In later posts I will show you how to automate this process using Model Builder and Python scripting.

Geoprocessing in ArcGIS

What is geoprocessing?

Geoprocessing is for everyone that uses ArcGIS. Whether you’re a new user or an old pro, geoprocessing will become an essential part of your day-to-day work with ArcGIS.

The fundamental purpose of geoprocessing is to allow you to automate your GIS tasks. Almost all uses of GIS involve the repetition of work, and this creates the need for methods to automate, document, and share multiple-step procedures known as workflows. Geoprocessing supports the automation of workflows by providing a rich set of tools and a mechanism to combine a series of tools in a sequence of operations using models and scripts.

The kinds of tasks to be automated can be mundane—for example, to wrangle herds of data from one format to another. Or the tasks can be quite creative, using a sequence of operations to model and analyze complex spatial relationships—for example, calculating optimum paths through a transportation network, predicting the path of wildfire, analyzing and finding patterns in crime locations, predicting which areas are prone to landslides, or predicting flooding effects of a storm event.

Geoprocessing is based on a framework of data transformation. A typical geoprocessing tool performs an operation on an ArcGIS dataset (such as a feature class, raster, or table) and produces a new dataset as the result of the tool. Each geoprocessing tool performs a small yet essential operation on geographic data, such as projecting a dataset from one map projection to another, adding a field to a table, or creating a buffer zone around features. ArcGIS includes hundreds of such geoprocessing tools.

Geoprocessing allows you to chain together sequences of tools, feeding the output of one tool into another. You can use this ability to compose an infinite of geoprocessing models (tool sequences) that help you automate your work and solve complex problems.

Tools and toolboxes

Geoprocessing tools perform small yet essential operations on geographic data, such as extracting and overlaying data; changing map projections; adding a column to a table; and calculating attribute values, polygon overlays, and optimal routes, to name a few. There are hundreds of tools at your disposal, and you can create your own tools using ModelBuilder, a visual programming language, or scripting, a text-based programming language.

Tools are stored in toolboxes. ArcGIS ships with hundreds of tools organized into a dozen or so toolboxes, providing a rich set of functionality across a wide range of disciplines.

To execute a tool, you must first find it. There are four ways to find a tool:

  1. A handful of commonly used tools can be found in the Geoprocessing menu found on the Standard toolbar. You can customize this list using Customize > Customize mode.
  2. Search for a tool in the Search window. Search allows you to enter keywords, short phrases that describe what the tool does.
  3. Browse for a tool in the Catalog window. Browse requires you know which toolbox contains the tool.
  4. Browse for a tool in the ArcToolbox window. The ArcToolbox window, like the Catalog window, displays toolboxes and tools as a tree view. You can add your custom toolboxes to the ArcToolbox window.

The most commonly used GIS tools automate tasks that were historically done manually—compiling new maps by overlaying one on top of the other or physically cutting maps into pieces representing specific study areas, then changing their projection. Some of these manual tasks were so arduous and complex that they held back the dissemination of geographic knowledge and data and were the primary impetus behind the invention of GIS.

Overlay and proximity

The first two sets of commonly used tools answer two of the most basic questions in geography: What’s on top of what? and What’s near what?


Geographic phenomena are not limited to discrete points, lines, and polygons but include data, such as elevation, slope, rainfall, and temperature, that varies continuously across the earth’s surface (or whatever planet or object you’re studying). Such continuous data is called a surface and is modeled with rasters and TINs.

Spatial and non-spatial statistics

One of the axioms of geography is that things that are close together are more similar than things that are farther apart. This axiom forms the basis of powerful spatial statistics tools that allow you to discover and characterize geographic patterns.

Table management

ArcGIS stores data in easily accessible tables, and the majority of workflows involve some sort of table management, such as adding or deleting fields, creating relationships between tables, or creating features from columns containing coordinates.

Selection and extraction

GIS datasets often contain much more data than you need, and a common set of tasks is to reduce or extract data from larger, more complex datasets.

Models and ModelBuilder

Geoprocessing allows you to chain together a sequence of tools, feeding the output of one tool into another. You use a geoprocessing model to chain tools together, and ModelBuilder, shown below, is how you create models.

Model Builder

Python and scripting

Python is a free, cross-platform, open-source programming language that is fast, powerful, and easy to learn. Python is considered a scripting (or interpretive) language, since it does not require a compiler. Programs that you write with Python are called scripts. There are other scripting languages besides Python, but ESRI has chosen Python as its preferred scripting language because of its power and wide acceptance.

Python is automatically installed when you install ArcGIS. All geoprocessing tools, as well as a wide variety of useful functions for interrogating GIS data, are available in the ArcPy site-package. A site-package is Python’s term for a library that adds additional functions to Python, and the ArcPy site-package is how GIS functions are added to Python. The ArcPy site-package is installed with ArcGIS. Using Python and the ArcPy site-package, you can develop an infinite number of useful programs that operate on geographic data.

There are three basic ways you can run Python code in ArcGIS:

  1. You can execute Python code interactively in the Python window, opened with the Python window button or by clicking Geoprocessing > Python. The Python window is an interactive window that lets you enter Python code, execute it immediately, and view the results in your active map.
  2. You can execute a Python script (a file with the .py extension) from the operating system prompt. Since you execute the script from the operating system prompt, you do not have to have an ArcGIS application running (such as ArcMap). Scripts that are executed from the operating system prompt are referred to as stand-alone scripts.
  3. You can create your own geoprocessing tool that executes a Python script. A tool that executes a script is called a script tool, and you can use a script tool like any other geoprocessing tool, embedding it in models or using it in other scripts. Script tools are not limited to Python scripts—you can create a script tool that executes anything, such as a JavaScript, AML, .bat, or .exe.

Python editor window