[GIS] How to find the destination point given a start point, distance and bearing

cogopostgisspherical-geometry

If I have a starting point as well as distance and a bearing to the destination point, how can I find the coordinates of the destination point using PostGIS?

I'm looking for a PostGIS equivalent to this function:
http://www.movable-type.co.uk/scripts/latlong.html#destPoint

Best Answer

This is basically the same thing I said here, just modified to produce the end point instead of a line:

SELECT
    objectid,
    ST_SetSRID(ST_Translate(ST_Rotate(ST_MakePoint(-1 * dist_field,0.0),
                                      radians(bearing_field)), ST_X(the_geom),  
                            ST_Y(the_geom)),ST_SRID(the_geom)) AS end_point_geom
FROM start_points

Where start_points is the table containing your starting points, the_geom in that table is the geometry column, dist_field is the distance field and bearing_field is the bearing field.

You may need to change the direction of the initial line (ST_MakePoint(-1 * dist_field,0.0)) to vertical (swap the coordinates/field name) depending on how you are measuring your bearing.