def go_meters(lon: float, lat: float, distance: float, bearing: float) -> Tuple[float, float]: """Returns a point in degrees longitude , latitude which lies at the specified distance and in the specified direction from the input point. Args: lon (float): Longitude in degrees lat (float): Latitude in degrees distance (float): Distance in meters bearing (float): Direction in degrees Returns: Tuple[float, float]: Longitude and Latitude of the resulting Point """ # https://stackoverflow.com/a/7835325 r = 6371000 brng = math.radians(bearing) #Bearing is 90 degrees converted to radians. lon1 = math.radians(lon) #Current lat point converted to radians lat1 = math.radians(lat) #Current long point converted to radians lat2 = math.asin(math.sin(lat1) * math.cos(distance/r) + math.cos(lat1) * math.sin(distance/r) * math.cos(brng)) lon2 = lon1 + math.atan2( math.sin(brng) * math.sin(distance/r) * math.cos(lat1), math.cos(distance/r) - math.sin(lat1) * math.sin(lat2) ) lat2 = math.degrees(lat2) lon2 = math.degrees(lon2) return (lon2, lat2)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter