Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a point layer and a line layer. The points are road junctions, collected using DGPS, while the lines are the connecting roads, collected through Handheld GPS in tracking mode. As a result, the lines are not actually connected to the points.

Sample Network Image

Now I want to:

  1. Remove all intermediate nodes from each line string, to make it a straight line.

  2. Snap the start & end vertex of lines to the nearest points.

I am using PostGIS 2.0.This by far what I have done:

SET geom = ST_Simplify(geom, 1000);

Q. Is there any other better way to accomplish it?(Since I am using an absurd tolerance)

SET geom = ST_AddPoint(
(SELECT geom FROM line WHERE id = 1),
(SELECT p.geom FROM point AS p, line AS l
    ORDER BY ST_Distance(p.geom,(SELECT ST_StartPoint(l.geom) FROM lt WHERE LIMIT 1),
WHERE id=1;

This will extend the line(with id=1) to the nearest point(point added at the beginning of the line).

Q. The above looks a bit complicated, is there any other efficient method/function available?

share|improve this question
I made suggestion in… - should I duplicate it here? – user1702401 Jan 4 '13 at 14:32

Since you don't need most of the data from the green lines, you could take a very simple (simplistic?) approach and make a a point file consisting of the start and end nodes of the green lines, attributed with a line ID. Then use the ST_Snap function to snap the new points to the existing intersections (red points). Then use the ST_MakeLine function to convert your snapped start/end points into your blue lines.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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