Geographic Information Systems Asked on July 30, 2021
I have a point, a line and a known angle. I want to project the point onto the line at that angle. In the below picture, I want to find the red point:
I think this may be possible by somehow using ST_Project, but it seems that it only works with geoography, not geometry. Even the example on the doc page says:
SELECT ST_AsText(ST_Project('POINT(0 0)'::geography, 100000, radians(45.0)));
st_astext
--------------------------------------------
POINT(0.635231029125537 0.639472334729198)
(1 row)
So, projecting a point by 100000 meters puts it at (0.635231029125537 0.639472334729198), which is definitely not right in a cartesian system.
Is there any way to wrangle it into use for geometry instead?
As an example of how to get results with ST_Project
, running
SELECT ST_Intersection(
ST_MakeLine(
ST_Transform(
ST_Project(
ST_Transform(
pt.geom,
4326
)::geography,
ST_MaxDistance(ln.geom, pt.geom),
radians(<angle_+_90°>)
)::geometry,
<projected_SRID>
),
pt.geom
),
ln.geom
) AS geom
FROM point AS pt,
line AS ln
would give you that point by reprojecting your geometries into EPSG:4326, casting them to geography type, projecting the point with a distance value determined by ST_MaxDistance
between the initial point and the line (Note: distance units will be returned in CRS units, ST_Project
treats units as meter; either your initial CRS has meter as units or you´ll need to reproject yet again...) and finding the intersection point between the created line and your initial line.
The measured azimuth on the projected data will be slightly off due to the conversions between geographical and projected CRS; ST_Project
and the geography type works with spheroidal algebra. To avoid that, maybe work with geographic CRS from the beginning.
Correct answer by geozelot on July 30, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP