# Calculate Volume over sloped ground in GRASS GIS

I am trying to do some volume calculations on a DEM with GRASS GIS.

However, I believe r.volume measures everything from 0.

The ground underneath the pile I'm measuring is sloped.

I would like to calculate the volume to reflect this, but I don't know the best way to go about it.

• Do you have two surfaces, i.e., one that represents the ground and the other that represents the pile? Is it possible to calculate the volume under the pile (from zero) and then subtract the volume of the sloped ground, which would give the true volume of the pile? Or is it that you have one surface with a pile on a surface, in which case you need to estimate the location of the ground beneath it? Oct 29, 2015 at 17:54
• I don't have the actual ground surface and I need to estimate it. I hope to be able to create a surface based on the heights of the pile footprint. Oct 30, 2015 at 15:09
• Does the ground estimation need to be mostly automated, or would it be ok for there to be a manual digitization step? Oct 30, 2015 at 20:07
• A manual step or two is no problem. I can figure out some kind of automation after I understand what's involved. Nov 1, 2015 at 1:57

Assuming you start with a DEM called terrain, I would try to:

I. Digitize a border around the pile. Either:

1. Prepare a text file with the polygon vertices. The format is called 'standard' and is described in https://grass.osgeo.org/grass64/manuals/v.in.ascii.html. It will look something like:
```B N
x1 y1
x2 y2
...
xN yN
x1 y1
```

where N is the number of vertices in one boundary. The structure repeats for more than one boundary. Then, import the text file: `v.in.ascii -n format=standard input=textFile.txt output=pile_boundary`

1. If you're using grass6, you might just be able to digitize the boundary using: v.digit -n map=pile_boundary bgcmd="d.rast map=terrain_surface"
2. For grass7, v.edit may help although I haven't used it.

II. Make a new terrain surface by punching out the pile and estimating the ground under the pile

``````# convert the digitized vector boundary to raster area
v.to.rast type=area use=cat input=pile_boundary output=pile_area
# punch out the pile and reinterpolate underneath it to estimate the terrain surface bellow the pile.
# FYI, grass 6 and 7 r.mapcalc syntax is a little different.
r.mapcalc expression='terrain_wo_pile=if(isnull(pile_area),terrain,null())'
r.fillnulls input=terrain_wo_pile output=terrain_below_pile
``````

III. Calculate the area of the pile itself

``````r.mapcalc expression='pile_height_above_terrain=terrain-terrain_below_pile'
r.volume data=pile_height_above_terrain clump=pile_area
``````