Volume height relation for a reservoir

Calculate the volume height relation for existing or potential reservoirs.

In this exercise we are going to calculate the water level – volume curve of the Ban Ve dam.

Step 1: import the upstream area:

// get the upstream area of the dam
var BanVEupstream = ee.FeatureCollection('ft:1z6zLTS1z5FlO1jizxY9g7k6-IIAcJvvT-5VxzVeL');
// add layer to map
Map.addLayer(BanVEupstream,undefined,"upstream area");

The dam is located at the red arrow


Step 2: Import the srtm and clip the basin

// import srtm data
var srtm = ee.Image("CGIAR/SRTM90_V4");
// clip ban ve area
var dem = srtm.clip(BanVEupstream);

var viz = {min:0, max:2000, palette:"000000,0000FF,FDFF92,FF2700,FF00E7"};
Map.addLayer(dem,viz,"elevation map");


Step 3: Add a recent sentinel 2 image for visual interpretation

// add recent s2 rgb image of reservoir
var img = ee.Image("COPERNICUS/S2/20160209T034234_20160209T090731_T48QVG");
Map.addLayer(img.clip(BanVEupstream),{min:0,max:3000,bands:"B4,B3,B2"},"sentinel 2 image") ;

Step 4: Create a list with water levels

// set list with water levels
var waterlevel = ee.List.sequence(155,220,1);

Step 5: Copy paste the function below. This function calculates water depth for different water levels using the digital elevation model.

// Function to calculate the volume in the reservoir
var calcVolume = function(level,list){

 // calculate area inundated
 var inundated = srtm.clip(BanVEupstream).lte(ee.Number(level));

 // calculate water level in each pixel
 var water = inundated.multiply(dem).subtract(ee.Number(level)).multiply(-1)

 // calculate area
 var area = inundated.multiply(30).multiply(30);

 // calculate volume
 var volume = area.multiply(water);

 // sum the volume
 var totalvolume = volume.reduceRegion(ee.Reducer.sum(), BanVEupstream);

 // retunr result to list
 return ee.List(list).add(totalvolume.get('elevation'));

Step 6: Apply the function above and put the values in an array

 // create emtpy list
var first = ee.List([]);

// iterate over water levels
var Volumes = ee.List(waterlevel.iterate(calcVolume, first));

 // set x an y values for list
var xValues = ee.Array(Volumes).divide(1000000000);
var yValues = ee.Array(waterlevel);

Step 7: Print the data as a chart.

//  Create the chart
var chart = ui.Chart.array.values(yValues, 0, xValues)
      title: 'Relation Volume Waterlevel',
      vAxis: {'title': 'water level (m)'},
      hAxis: {'title': 'Volume (billion m3)'},
      pointSize: 3,

// Print the chart.



Follow this link for the full code.


One thought on “Volume height relation for a reservoir”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s