[postgis-users] Get point certain degree of another point

Maelvon HAWK maelvon.hawk at laposte.net
Mon Mar 1 09:15:05 PST 2010


Le 28/02/2010 17:11, Mike Toews a écrit :
>
> Apply the same COGO trigonometry as before[1]:
>
> import math
>
> class Point:
>      def __init__(self, x, y):
>          self.x=x; self.y=y
>
> def TranslateBearingDistance(pt, rad, dist):
>      return Point(pt.x + dist*math.cos(rad), pt.y + dist*math.sin(rad))
>
> pt0 = Point(100, 100)
>
> # 12 units away at 30 degrees CCW from x-axis
> pt1 = TranslateBearingDistance(pt0, 30*2*math.pi/360, 12)
>
> print pt1.x, pt1.y
> # 110.392304845 106.0
>
>
> [1] http://www.mail-archive.com/postgis-users@postgis.refractions.net/msg09702.html
>
> -Mike

Thanks Mike for the tip.

After that I've found the geopy[1] library, finally :

from geopy import distance
pt1 = (40.14603,0.86791)
distance = distance.VincentyDistance
distance = distance(kilometers=1.)
distance.destination(pt1, 60, 0.5)
# Point(46.148278989214596, 0.97351489536992275, 0.0)

[1] http://code.google.com/p/geopy/wiki/Installation

Maelvon HAWK



More information about the postgis-users mailing list