Skip to content

Coordinates + xy offset or heading & distance to new coordinate? #506

Answered by lucasw
lucasw asked this question in Help
Discussion options

You must be logged in to vote

I think destination is it https://geopy.readthedocs.io/en/stable/#geopy.distance.Distance.destination

import geopy


loc0 = (50.0, -120.0)

# 0.0 is north, 90.0 is east, etc.
heading_degrees = 90.0
distance0 = 1000.0
print(f"heading degrees {heading_degrees}, distance to travel {distance0} meters")
print(f"start location:        {loc0}")

loc1_pt = geopy.distance.distance(meters=distance0).destination(loc0, bearing=heading_degrees)
loc1 = (loc1_pt.latitude, loc1_pt.longitude)
print(f"destination location:  {loc1}")

distance1 = geopy.distance.distance(loc0, loc1).meters
print(f"{distance1} meters traveled, error {distance1 - abs(distance0)}")
heading degrees 90.0, distance to travel 1000…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lucasw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant