如何计算地图上多边形的面积?
要求:我们可以在地图上计算多边形的面积,即
我们有多边形坐标,可以找到多边形的区域。 面积将是英亩和公顷
coordinates is: [
[10.075854059674523, 76.32832467556],
[10.079825860518895, 76.33338868618011],
[10.076234340596953, 76.33806645870209],
[10.07065684212598, 76.33806645870209],
[10.068924417668397, 76.33175790309906]
]
答案 0 :(得分:1)
来自polygon
的公式,
Area of ploygon = [(x1y2-x2y1) + (x2y3-x3y2) + .... + (x(n-1)yn - y(n-1)xn)]/2
尝试,
var arr=[
[10.075854059674523, 76.32832467556],
[10.079825860518895, 76.33338868618011],
[10.076234340596953, 76.33806645870209],
[10.07065684212598, 76.33806645870209],
[10.068924417668397, 76.33175790309906]
];
var sum=0;
for(var i=0,l=arr.length-1;i<l;i++){
sum+=(arr[i][0]*arr[i+1][1]-arr[i+1][0]*arr[i][1]);
}
alert('The Area of Ploygon is:'+(sum/2));