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
rasterArea=gp.searchCursor(reservoir_area)
rasRow=rasterArea.next()
while rasRow:
rasCount=rasRow.getValue('Count')
rasValue=rasRow.getValue('Value')
rasvol=rasvol + rasCount*rasValue*cellarea
rasRow=rasterArea.next()
This code is correct or not for calculating the volume ?
Best Answer
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.
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.
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.