简体   繁体   English

使用 python 根据原点、终点、中心、距离和方位计算圆弧坐标

[英]Calculate arc coordinates based on original point, end point, center, distance and bearing using python

Having the following information:具有以下信息:

  • Origin point: Point(lat_origin, long_origin)原点:Point(lat_origin, long_origin)
  • End point: Point(lat_end, long_end)终点:Point(lat_end, long_end)
  • Center point: Point(lat_center, long_center)中心点:Point(lat_center, long_center)
  • Distance: 100距离:100
  • Bearing: 90º轴承:90º
from shapely.geometry import Point
origin_point = Point(...,...)
end_point = Point(...,...)
center_point = Point(...,...)
distance = 100
bearing = 90

I would like to be able to generate an arc as close as possible with as few points as possible, obtaining the coordinates of this approximation.我希望能够用尽可能少的点生成尽可能接近的弧,从而获得这个近似值的坐标。

A good functionality would be to be able to control the error tolerance and to be able to dynamically graduate the number of points to approximate the arc.一个好的功能是能够控制误差容限并能够动态地调整点的数量以接近弧线。

We must have in mind that we are working with coordinates and we cannot ignore surface curvature.我们必须记住,我们正在使用坐标,我们不能忽略曲面曲率。

The expected output would be a function that obtains as inputs, the origin point, the end point, center point, distance, bearing and optionally the error tolerance and returns as output a series of point coordinates from the original point to the end point that approximately form the required arc.预期的 output 将是一个 function 作为输入获得,原点,终点,中心点,距离,方位和可选的误差容限,并返回 Z78E6221F6393D1356681DB398F14CE 的一系列点坐标形成所需的弧线。

Related links:相关链接:

https://gis.stackexchange.com/questions/326871/generate-arc-from-projection-coordinates https://gis.stackexchange.com/questions/326871/generate-arc-from-projection-coordinates

Any help would be greatly appreciated.任何帮助将不胜感激。

https://www.igismap.com/formula-to-find-bearing-or-heading-angle-between-two-points-latitude-longitude/ https://www.igismap.com/formula-to-find-bearing-or-heading-angle-between-two-points-latitude-longitude/

import math
import numpy as np
from shapely.geometry import Point, LineString

def get_bearing(center_point, end_point):
    
    lat3 = math.radians(end_point[0])
    long3 = math.radians(end_point[1])
    lat1 = math.radians(center_point[0])
    long1 = math.radians(center_point[1])
    
    dLon = long3 - long1
    
    X = math.cos(lat3) * math.sin(dLon)
    Y = math.cos(lat1) * math.sin(lat3) - math.sin(lat1) * math.cos(lat3) * math.cos(dLon)
    
    end_brng = math.atan2(X, Y)
    
    return end_brng

def get_arc_coordinates(center_point, origin_point, end_point, brng_init, distance):
    '''
    center_point: (center_latitude, center_long) 
    origin_point: (origin_latitude, origin_long) 
    end_point: (end_latitude, end_long)
    brng_init: degrees
    distance: aeronautical miles
    '''
    
    brng_init = math.radians(brng_init) #Bearing in degrees converted to radians.
    d = distance * 1.852 #Distance in km
    
    R = 6378.1 #Radius of the Earth
    brng = get_bearing(center_point,end_point) #1.57 #Bearing is 90 degrees converted to radians.
    
    list_bearings = np.arange(brng, brng_init, 0.1) # 0.1 value to be modify with tolerance
    
    coordinates = []
    
    for i in list_bearings:
        lat1 = math.radians(center_point[0]) #Center lat point converted to radians
        lon1 = math.radians(center_point[1]) #Center long point converted to radians
        brng = i
        lat2 = math.asin( math.sin(lat1)*math.cos(d/R) +
             math.cos(lat1)*math.sin(d/R)*math.cos(brng))
        
        lon2 = lon1 + math.atan2(math.sin(brng)*math.sin(d/R)*math.cos(lat1),
                     math.cos(d/R)-math.sin(lat1)*math.sin(lat2))
        
        lat2 = math.degrees(lat2)
        lon2 = math.degrees(lon2)
        
        coordinates.append(Point(lat2, lon2))

    return LineString(coordinates)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 根据距离和方向计算点 - Calculate point based on distance and direction 根据距离点的距离过滤坐标 - Filtering coordinates based on distance from a point Python PyQt5 二维图形应用:如何画两个端点坐标的线和两个端点和一个圆心坐标的圆弧 - Python PyQt5 2D graphics application: How to draw lines with two end point coordinates and arcs with two end and a center point coordinates 计算给定点、方位和距离的 GPS 坐标 - calculating a gps coordinate given a point, bearing and distance Python Dataframe 通过中间点计算距离 - Python Dataframe calculate Distance via intermediate point 计算 DataFrame 中固定点的两个坐标之间的距离 - Calculate distance between two coordinates for a fixed point in a DataFrame 在底图已知起点和方位的情况下绘制大圆弧 - drawing great circle arc with Basemap knowing starting point and a bearing 通过角度和长度计算线的端点坐标 - Calculate coordinates of end point of a line by having the angle and the length 获取给定当前点、距离和方位的纬度/经度 - Get lat/long given current point, distance and bearing 根据给定的距离和从样条线的方位移动xy坐标 - Move xy coordinates based on a given distance and bearing from transect
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM