How to find hypotenuse using python code

799
1
12-13-2017 07:37 AM
MonicaBeaton
New Contributor III

I have a polyline feature class (sewer pipes) with upstream and downstream values but because the z values are not enabled on the dataset, I need a quick way to produce a "true length" or 3D value. How can I plug into the field calculator:

(upstream - downstream) squared + shape.length squared = hypotenuse? using python (or VB?)

Thanks to anyone, I am not a coder just a novice with python still.

I should add that I have created a new field called True_Len to calculate the result on, not trying to change an existing field value.

Tags (2)
0 Kudos
1 Reply
MonicaBeaton
New Contributor III

For anyone with the same question; after a few trials, my colleague and I came up with this:

math.sqrt((!Shape_len! * !Shape_len!) + ((!UpstreamIn! -  !Downstream!) * ( !UpstreamIn! - !Downstream!)))

There's likely an easier way to produce the same results but isn't that the same with most geoprocessing?

0 Kudos