3π
β
You can accomplish this using the Geod class of pyproj.
from pyproj import Geod
geoid = Geod(ellps='WGS84')
def add_distance(lat, lng, az, dist):
lng_new, lat_new, return_az = geoid.fwd(lon, lat, az, dist)
return lat_new, lng_new
- lng: starting longitude
- lat: starting latitude
- az: azimuth, the direction of movement
- dist: distance in meters
So for your specific question, you could do the following:
from django.contrib.gis.geos import Point
def move_point_mile_east(point):
dist = 1609.34
lat, lng = add_distance(point.y, point.x, 90, dist)
return Point(lng, lat)
π€roob
0π
Please note there appears to be a typo in the answer by roob above. In the definition of the add_distance
function the argument lng
is used, but then in the body of that function the variable lon
is used. These need to be the same, of course.
Otherwise itβs an excellent answer. Thank you.
π€allan
Source:stackexchange.com