AshClarke
AshClarke

Reputation: 3078

Maps api geometry library for python

Using javascript google maps geometry apis, I can compute the coordinates of a second point, by giving the coordinates of a first point, distance required and angle. eg.

var point = new google.maps.LatLng(55.623151, 8.48215);
var spherical = google.maps.geometry.spherical; 
var north = spherical.computeOffset(point, 5000, 0); 

However, I'm working with python with google app engine and just wondering how I would go about doing this in python and GAE.

I've looked around for a python library that would do the same thing. I don't want to go grey by trying to reinvent the wheel.

Upvotes: 0

Views: 1633

Answers (1)

AshClarke
AshClarke

Reputation: 3078

I solved this by using VincentyDistance in GeoPy.

import geopy
from geopy.distance import VincentyDistance
import math

lat1 = -27.413224
lng1 = 152.789183
angle = 90 //in degrees

d = 50 //destination length required
origin = geopy.Point(lat1, lng1)

destination = VincentyDistance(meters=d).destination(origin, angle)

lat2 = destination.latitude
lng2 = destination.longitude

Upvotes: 5

Related Questions