Select to view content in your preferred language

Why `geometryEngine.planarArea` does not match the results calculated by the Shoelace formula

554
1
Jump to solution
05-23-2022 07:41 PM
yujinpan
New Contributor

I created an instance and listed two calculation results, the result of `planarArea` is 20423.311146823657, and the result of `Sholace formula` is 20423.328125, the difference is -0.016978176343400264, why is this?

https://codepen.io/yujinpan/pen/BaYwLPG?editors=1001

Here is my calculation.

// Shoelace formula
let total = 0;
coordinates.forEach(([x, y], index, arr) => {
const [nextX, nextY] = arr[index + 1] || arr[0];
total += (x*nextY - nextX*y)*0.5;
});

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

if the units are meters, then the difference is about 2 millimeters squared over a total area 20 thousand-ish meters squared.

floating point precision and/or math package differences

different methods of calculating area

shoelace doesn't know about coordinate systems

 

some possibilities.  


... sort of retired...

View solution in original post

1 Reply
DanPatterson
MVP Esteemed Contributor

if the units are meters, then the difference is about 2 millimeters squared over a total area 20 thousand-ish meters squared.

floating point precision and/or math package differences

different methods of calculating area

shoelace doesn't know about coordinate systems

 

some possibilities.  


... sort of retired...