0

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?

  • 3
    Which error are you getting? Please edit your question to include it in the text. – lambertj May 13 at 17:23
  • 3
    In the code posted above you are missing a multiplication symbol between the second radius calculation and math.pi. There's also no operator listed between 144 and !Shape.STLength()!. – smiller May 13 at 18:37
4

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:

(!DIAMETER!/2)*( !DIAMETER!/2)*math.pi/144*!Shape.STLength()!*7.48

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. Assuming 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.

  • Guess: 144 is square inches to square feet. I don't think you can assume the projection influences the units of DIAMETER. – Richard Morgan May 13 at 19:46
  • Ah, thanks for the clarification. I'll update. – smiller May 13 at 19:54
  • When I do this calculation in ArcMap using data that has the field !Shape_Length! it works fine, but when I use data that has the shape field "Shape_STLength()! it doesn't recognize the field .... – Ren May 16 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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