Skip to main content

assuming that your data is correct., try this:

SELECT ST_GeomFromText('LINESTRING(' || a.start || ' , ' || a.end || ')') FROM (
 SELECT ST_StartPoint(geom) as start, ST_EndPoint(geom) as end FROM roads) as a

SELECT ST_GeomFromText('LINESTRING(' || a.start || ' , ' || a.end || ')') FROM ( SELECT ST_StartPoint(geom) as start, ST_EndPoint(geom) as end FROM roads) as a (not tested, probably has syntax errors).

Add WHERE clause if needed.

assuming that your data is correct.

SELECT ST_GeomFromText('LINESTRING(' || a.start || ' , ' || a.end || ')') FROM ( SELECT ST_StartPoint(geom) as start, ST_EndPoint(geom) as end FROM roads) as a (not tested, probably has syntax errors)

Add WHERE clause if needed

assuming that your data is correct, try this:

SELECT ST_GeomFromText('LINESTRING(' || a.start || ' , ' || a.end || ')') FROM (
 SELECT ST_StartPoint(geom) as start, ST_EndPoint(geom) as end FROM roads) as a

(not tested, probably has syntax errors).

Add WHERE clause if needed.

Source Link
simpleuser001
  • 3.9k
  • 18
  • 21

assuming that your data is correct.

SELECT ST_GeomFromText('LINESTRING(' || a.start || ' , ' || a.end || ')') FROM ( SELECT ST_StartPoint(geom) as start, ST_EndPoint(geom) as end FROM roads) as a (not tested, probably has syntax errors)

Add WHERE clause if needed