zoukankan      html  css  js  c++  java
  • 根据经纬度计算多边形的面积

    这里有个前提是:你的经纬度点是依次相连接的点,不是无序的,可以是顺时针,或者逆时针都可以。

    附python代码:

    import math
    def ConvertToRadian(input):
    return input * math.pi / 180;
    def CalculatePolygonArea0(data):
    area = 0;
    arr = data.split(';')
    arr_len = len(arr)
    if arr_len < 3:
    return 0.0
    temp = []
    for i in range(0, arr_len):
    temp.append([float(x) for x in arr[i].split(',')])
    for i in range(0, arr_len):
    area += ConvertToRadian(temp[(i + 1) % arr_len][0] - temp[(i) % arr_len][0]) * (2 + math.sin(ConvertToRadian(temp[(i) % arr_len][1])) + math.sin(ConvertToRadian(temp[(i + 1) % arr_len][1])));
    area = area * 6378137.0 * 6378137.0 / 2.0;
    return round(math.fabs(area),6);
    if (__name__ == "__main__"):
    data = "115.989099,39.646023;115.987394,39.645988;115.987371,39.647407;115.986684,39.647423;115.986602,39.648088;115.989095,39.648151;115.989188,39.646021;115.989099,39.646023"

    print(CalculatePolygonArea0(data))
    
    

    Calculate the area of polygon according to the longitude and latitude.

    assuming your source is WGS1984, if not then you'll need to adjust the ellipsoid used by the  line(

    area = area * 6378137.0 * 6378137.0 / 2.0;

    ).

    我站在远处,就这样看着,一句话也不说。
  • 相关阅读:
    thinkphp--标签库
    thinkphp中的参数绑定
    thinkphp3.2.3子查询中遇到的错误
    开篇马克
    BST树、B-树、B+树、B*树
    linux shell编程之变量和bash配置文件(第一篇)
    linux awk进阶篇
    linux awk(gawk)
    linux sed命令
    linux basic
  • 原文地址:https://www.cnblogs.com/c-w20140301/p/10308431.html
Copyright © 2011-2022 走看看