# 根据经度、纬度计算两地距离: def get_distance2(lat1, lon1, lat2, lon2): """获取地理坐标系下的两点间距离""" # GetDistanceInGeographyCoordinate, return two point distance radius_lat1 = lat1 * math.pi / 180 radius_lat2 = lat2 * math.pi / 180 radius_lon1 = lon1 * math.pi / 180 radius_lon2 = lon2 * math.pi / 180 a = radius_lat1 - radius_lat2 b = radius_lon1 - radius_lon2 distance = 2 * math.asin(math.sqrt( pow(math.sin(a / 2.0), 2) + math.cos(radius_lat1) * math.cos(radius_lat2) * pow(math.sin(b / 2.0), 2))) distance = distance * 6378137 distance = distance - (distance * 0.0011194) return distance #方位角 def get_bearing(lat1, lon1, lat2, lon2): dlon = lon2 - lon1 y = math.sin(dlon) * math.cos(lat2) x = math.cos(lat1) * math.sin(lat2) - math.sin(lat1) * math.cos(lat2) * math.cos(dlon) bearing = math.atan2(y, x) bearing = np.degrees(bearing) bearing = (bearing + 360) % 360 return bearing