I'm trying to do this calculation:
(!DIAMETER!/2)*( !DIAMETER!/2)math.pi/144 !Shape.STLength()!*7.48
and keep getting an error.
Can anyone give me the correct syntax for calculating the volume of a water pipe?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
The code you posted is missing a multiplication symbol between the second radius calculation and math.pi. There is also no operator listed between 144 and !Shape.STLength()!
Assuming the rest of your calculation is correct and that the missing operator is multiplication:
You likely also have to
import math before running this.
However -- In general, volume for a cylinder is
pi * radius squared * height
It's unclear to me why you are using the 144 and 7.48 in this calculation.
height = !Shape.STLength()!, wouldn't the volume just be:
volume = math.pi * (!DIAMETER!/2) * ( !DIAMETER!/2) * !Shape.STLength()!
It's possible that you're looking for volume in gallons, in which case the 7.48 makes more sense (~7.48 gallons in a cubic foot). You'll want to verify that the underlying projection (and thus the values for
!Shape.STLength()!) uses feet. Once you have the cubic feet, just multiply by 7.48.
volume_gallons = math.pi * (!DIAMETER!/2)*( !DIAMETER!/2) * !Shape.STLength()!*7.48
or more compactly:
volume_gallons = (!DIAMETER!/2)**2 * math.pi * !Shape.STLength()! * 7.48
The 144 may represent the calculation between square inches and square feet; double-check your units to confirm. Please edit your question to include any errors received.