# python计算高德地图距离和面积

## python计算高德地图距离和面积

from math import asin,sqrt,cos,pi

#point_a,point_b是经纬度,格式为[lng,lat]
def st_distance(point_a,point_b):
#弧度
#地球半径

e = (1 - cos(h - f) + (1 - cos(d)) * cos(f) * cos(h)) / 2
return k * asin(sqrt(e))
print(round(st_distance([116.434027, 39.941037],[116.461665, 39.941564]),1))

from math import cos,pi

def st_area(wkt_list):
# 弧度
# 地球半径
# 地球弧度
# 面积
area = 0

length = len(wkt_list)
if length < 3 :
return 0
for index in range(0,length-1):
front_point = wkt_list[index]
rear_point = wkt_list[index+1]

area += (front_sector * rear_point[1] * earth_radian - rear_sector * front_line)
wkt_rear = wkt_list[length-1]
wkt_front = wkt_list[0]
area += wkt_rear_sector * wkt_front[1] * earth_radian - wkt_front_sector * wkt_rear_line
return 0.5 * abs(area)/1000000

def format_wkt(wkt):
point_list = wkt.split(',')
wkt_list=[]
for point in point_list:
lng,lat = point.split(' ')
wkt_list.append([float(lng),float(lat)])
return wkt_list

#计算面积
wkt='121.543409 31.256203,121.526242 31.248425,121.497403 31.248572,121.48367 31.253268,121.476632 31.267355,121.48161 31.280853,121.492253 31.289508,121.511479 31.292736,121.530362 31.293176,121.544782 31.285401,121.551992 31.270876,121.555253 31.264274,121.543409 31.256203'
print(round(st_area(format_wkt(wkt)),2))

05-24 3736

09-16 3070

06-21 5万+

06-01 2693

04-18 6783

#### 根据经纬度点计算区域面积

©️2020 CSDN 皮肤主题: 技术工厂 设计师: CSDN官方博客

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。