ST_Project — Returns a point projected from a start point by a distance and bearing (azimuth).
geometry ST_Project(geometry
g1, float
distance, float
azimuth);
geometry ST_Project(geometry
g1, geometry
g2, float
distance);
geography ST_Project(geography
g1, float
distance, float
azimuth);
geography ST_Project(geography
g1, geography
g2, float
distance);
Projects a point by a given distance and azimuth (bearing). For geography, it follows a geodesic and the distance is in meters. For geometry, it follows a straight line in the coordinate plane and the distance is in the units of the input CRS.
The two-point version takes its initial bearing from the first point toward the second and projects from the second point. Negative distances project in the opposite direction.
The azimuth is in radians, measured clockwise from true north for geography and clockwise from the positive Y axis for geometry.
North is azimuth zero (0 degrees)
East is azimuth π/2 (90 degrees)
South is azimuth π (180 degrees)
West is azimuth 3π/2 (270 degrees)
Negative azimuth values and values greater than 2π (360 degrees) are supported.
Availability: 2.0.0
Enhanced: 2.4.0 Allow negative distance and non-normalized azimuth.
Enhanced: 3.4.0 Allow geometry arguments and two-point form omitting azimuth.
Project a point 100,000 meters at a bearing of 45 degrees.
SELECT ST_Project('POINT(0 0)'::geography, 100000, radians(45.0));
POINT(0.635231029125537 0.639472334729198)
Project one unit north from the equator. For EPSG:4326 geometry the unit is one degree. For geography the unit is one meter.
SELECT ST_Y(ST_Project('SRID=4326;POINT(0 0)'::geometry, 1, 0))
AS geometry_latitude,
round(ST_Y(ST_Project('POINT(0 0)'::geography, 1, 0)::geometry)::numeric, 10)
AS geography_latitude;
geometry_latitude | geography_latitude
-------------------+--------------------
1 | 0.0000090437
(1 row)
Extend or shorten a line using its endpoints.
SELECT ST_AsText(ST_Project('POINT(0 0)'::geometry,
'POINT(2 0)'::geometry, 1)) AS projected_point,
ST_AsText(ST_Project('POINT(0 0)'::geometry,
'POINT(2 0)'::geometry, -1)) AS opposite_direction;
projected_point | opposite_direction -----------------+-------------------- POINT(3 0) | POINT(1 0) (1 row)