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?
I would have expected the two lengths to be the same.
Thanks! I happen to be using a file geodatabase directly, not a feature service. Any idea if that blurb applies to FGDBs?
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:
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
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.
Granted this is a very small test (4 lines), but maybe all this will help you toward you goal.
K
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.
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)