2

I have a point layer punkte_test. From that I want to make a line: first point of the line is the point A from the point layer itself. Second point of the line shall be y(B) = y(A) - 500 m . How can I realize that?

That's my idea:

SELECT ST_MakeLine(geom, concat(ST_X(geom), (ST_Y(geom)-500)))
FROM liechtenstein.punkte_test

I use coordinate system UTM, so I want the second point to be 500 m south of A.

2
  • You can maybe use ST_MakePoint instead of your "concat" : postgis.net/docs/ST_MakePoint.html – J. Monticolo Jan 20 at 12:19
  • 1
    yeah, thats right. SELECT ST_MakeLine(geom, st_setsrid(ST_MakePoint(ST_X(geom), (ST_Y(geom)-500)),25832)) FROM liechtenstein.punkte_test gives the line – KerryKilian Jan 20 at 12:27
6

You can use st_translate to move the point

SELECT ST_MakeLine(geom, st_translate(geom,0,-500))
FROM liechtenstein.punkte_test;
1
  • uhh nice thats also a good idea – KerryKilian Jan 20 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.