Why is Arcade Length() different from Shape_Length?

1139
4
02-28-2022 12:40 PM
Bud
by
Notable Contributor

 

Arcade — ArcGIS Pro 2.9 — FGDB:

I have a Arcade_Length field in a polyline FGDB FC that I populate using a Calculation Attribute Rule:

Length($feature)


Question:

Why is the Length($feature) value different from the Shape_Length value?

Bud_1-1646080326319.png

I would have expected the two lengths to be the same.

 

0 Kudos
4 Replies
KimGarbade
Occasional Contributor III

I would image this is why... from Geometry Functions | ArcGIS Arcade | ArcGIS Developer

KimGarbade_0-1646087936495.png

 

0 Kudos
Bud
by
Notable Contributor

Thanks! I happen to be using a file geodatabase directly, not a feature service. Any idea if that blurb applies to FGDBs?

0 Kudos
KimGarbade
Occasional Contributor III

You know I don't know that... but I'll run an experiment using similar code at different scales and keep you posted what I find out.

Looks like it doesn't.  Here is the Arcade Length of these lines at 1:100 / 1:1,000 / and 1:10,000 (with an extra test for converting $feature to geometry first) all come up with the same (albeit wrong) length value:

KimGarbade_0-1646105575200.png

I thought maybe it had to do with the map being in one spatial reference and the data being in another, but the above numbers were generated when both were set to

KimGarbade_1-1646106151944.png

Then I read about the Arcade LengthGeodetic function and thought it might have something to do with the curvature of the Earth.  So I created some test data in WGS 84 Web Mercator (aux sphere) and created a map using that same spatial reference and ran a test on that using just straight up Length($feature,'meters') and got the below results, which you might be interested in.  The only line who's length was different between shape length and the ArcadeLength in this test was the line that contained the true curve.

KimGarbade_2-1646106615138.png

Granted this is a very small test (4 lines), but maybe all this will help you toward you goal.

K

Bud
by
Notable Contributor

Thanks!

I'm wondering if the core issue is that the geometries in Arcade get automatically densified (at least, I think they do).

 

Additionally, I think I might have found a workaround.

Instead of using Length($feature) which gives the wrong length, I think we can use $feature.shape_length  which gives the right length.

Bud_1-1646165284297.png


I wonder if the reason Esri auto-densifies geometries is for the scenario that you mentioned — generalizing in different scales when used in feature services. Maybe that's the why here.
Or maybe, it's just because true curves are a pain, and are easier to deal with if they're always automatically densified.


Related:
Calculate length of line without using length function (and without densifying curves)

0 Kudos