Select to view content in your preferred language

Distance in Geometry Engine is incorrect

3333
7
07-06-2016 04:45 AM
BenjaminKim1
Emerging Contributor

I have noticed NearMe widget displays incorrect distance. Does anyone have this problem?  I looked into code and I have found out that NearMe widget uses Geometry Engine to calculate distance between two geometries. Maybe this is a bug with Geometry Engine. ESRI needs to fix this bug.

0 Kudos
7 Replies
RobertScheitlin__GISP
MVP Emeritus

Benjamin,

What criteria have you used to determine it is the incorrect distance? Are you using a esri basemap or is your map in a planar SR?

BenjaminKim1
Emerging Contributor

I am using my own base map which is in Web Mercator coordinate. The distance from Geometry Engine is larger (50~100 ft) than the Measurement widget result and that is why I think something must be wrong with Geometry Engine distance.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Benjamin,

  Are you zoomed in and using snapping when measuring? 50 ~ 100 ft is quite easy to mistakenly measure if zoomed out. A lot of testing has gone into the GeometryEngine so I am less likely to believe that it is the issue or else LOTS of people would be screaming about this.

0 Kudos
BenjaminKim1
Emerging Contributor

I have zoomed in to verify the distance and I don't use snapping. This is the first time I am using Geometry Engine in my JS app and maybe I am using it incorrectly. Although my base map is in Web Mercator all the operational layers are in state plane and they are re-projected to Web Mercator on the fly.

In order to use Geometry Engine do all operational layers need to be in Web Mercator as well?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Benjamin,

  No the only one that matters is the basemap as that is the one that sets your maps SR. Are you using geodesicLength or planarLength methods?

0 Kudos
BenjaminKim1
Emerging Contributor

Thanks Robert for helping me in this issue.

I ended up writing my own function returning correct distance using Geometry Service instead of Geometry Engine. ''distParams.geodesic = true'' returns correct distance. I still wonder why Geometry Engine does not work with my data...

Anyway your answer in this question also helped me a lot

Looping with GeometryService Distance (deferred problem?)

Thank you very much

0 Kudos
KristianEkenes
Esri Regular Contributor

Benjamin,

Could you clarify which geometryEngine method(s) you were using? Was it the distance() method? If so, then I would suspect it's the issue Robert pointed out - That you are calculating web mercator coordinates with planar measurements (distance() is a planar measuring tool, not geodesic). Therefore the calculation itself was likely correct, but the WebMercator projection was distorting the true measurement.

Rather than using distance or planarLength(), I would suggest you use geodesicLength() instead if you are working in WebMercator. This allows you to get more correct measurements in a distorted projection with the benefit of keeping all calculations on the client and not having to make extra network requests. I encourage you to read this blog post that discusses this in more detail here - GeometryEngine part 2: Measurement | ArcGIS Blog

Be sure to note the differences between distance() and geodesicLength() - distance takes in two input points, whereas geodesicLength() takes in a polyline. So if measuring the distance between two points, you will first need to create a polyline with those two points as beginning and ending vertices on the path. Let me know if you're still stuck with this.

0 Kudos