Select to view content in your preferred language

Why esri.geometry.getLength() and esri.geometry.geodesicLengths() are incompatible?

1974
4
07-25-2011 01:08 AM
YardenCochav
Deactivated User
Hello,
When I calculate length of 2 points in METERS in webmercator SR, I received inconsistent results with esri.geometry.getLength() and esri.geometry.geodesicLengths():

esri.geometry.geodesicLengths() result gives a number that is 15%-20% lower than the result of
esri.geometry.getLength().
On what function should I rely on?
Why this happens? what is more accurate?

Thanks!!!!
0 Kudos
4 Replies
derekswingley1
Deactivated User
They do two different things.

getLength calculates a Eudclidean distance AKA planar distance which assumes the world is flat. This is appropriate for short distances and/or when you're using a projected coordinate system, e.g. a UTM zone or State Plane.

geodesicLengths calculates a geodesic distance which is a measurement on a sphere. This is appropriate when you're measuring long distances on a globe.

I'll also throw in a plug for a blog post Sterling from the server team did a while back about using the right coordinate system when measuring distances in a web app:  Measuring distances and areas when your map uses the Mercator projection.
0 Kudos
YardenCochav
Deactivated User
Thank you so much.
I read this great post yesterday when I looked for articles regarding measurements, and it helped me a lot.
I have another question regarding the geodesicLength(). Is there a bug when using it in web-Mercator Bing maps? because i received  "0" or "NaN" value when measuring polyline of 2 points.

Thanks!
0 Kudos
derekswingley1
Deactivated User
Does this thread describe your problem?
0 Kudos
derekswingley1
Deactivated User
Oops, previously forgot a link to the thread I was referencing. I updated my post. Not sure if the forum notifies you when I edit so I'm posting again...
0 Kudos