Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a raster file containing the depth of water. I need to find the volume of water using that raster file. I need to find the area of each cell and multiply with the depth. How can I do it in Python using ArcGIS 10 ?

rasvol = 0
while rasRow:
     rasvol=rasvol + rasCount*rasValue*cellarea

This code is correct or not for calculating the volume ?

share|improve this question

1 Answer 1

If your raster has cells of equal size then the area is easy enough, as its just the cells size squared. Then you could use the Spatial Analyst - Math - Times tool to multiply each cell times its area to get a raster representing the volume for each cell.

import arcpy
from arcpy.sa import *
outVol = Times("depth", "100")

One method to get the total would be to convert the raster to a numpy array and then to just take the sum of that array.

import numpy 
myArray = arcpy.RasterToNumPyArray(outVol)
totVolume= numpy.sum(myArray)

If the cells are of a different size then your best bet might be to convert the raster to a polygon and calculate the area of each cell.

share|improve this answer
Sorry I could not get what I was expecting –  Ja Geo May 3 '13 at 19:33
I have written code to find the volume. Actually I have raster image of water depths. My image resolution is 30*30. Now I need volume of water –  Ja Geo May 3 '13 at 19:34
Please check my below code whether it is correct to solve my problem or not..please give me feedback –  Ja Geo May 3 '13 at 19:44
I have tried to numpy arry but i don't know why i am getting negative result ? –  Ja Geo May 16 '13 at 3:32
Are depths negative values in your raster file? –  JeremyFon May 16 '13 at 11:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.