Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

In QGIS, i would like to create a new layer containing the beginning and end points of a polylines layer, but without the duplicate points that would result of adjacent polylines.

share|improve this question

2 Answers 2

create 4 point from 2 line:

SELECT (row_number() OVER () )AS id, A1.gid as orginalgid, p as startorend ,A1.geom FROM ((SELECT DISTINCT gid, 'ep' as p , st_endpoint(st_linemerge(tmpsel.geom)) AS geom FROM tmpsel) UNION (SELECT DISTINCT gid, 'sp' as p, st_startpoint(st_linemerge(tmpsel.geom)) AS geom FROM tmpsel)) AS A1;

share|improve this answer
up vote 0 down vote accepted

As my layers loaded in QGIS Map Canvas are loaded from postgis, i used the st_endpoint() and st_startpoint() Postgis functions to find the start and end point of each polyline and i made a union of both SQL to remove the duplicates. It works perfect loading the SQL with the DB Manager to QGIS Map Canvas. I added a (row_number() OVER () AS id) sentence to create a unique identifier that the DB Manager needed. The query would be:

SELECT (row_number() OVER () AS id, A1."GEOMETRY" FROM (SELECT DISTINCT st_endpoint(YOUR_TABLE."GEOMETRY") AS "GEOMETRY" FROM YOUR_TABLE) UNION (SELECT DISTINCT st_startpoint(YOUR_TABLE."GEOMETRY") AS "GEOMETRY" FROM YOUR_TABLE)) AS A1;

Regards,

share|improve this answer

Your Answer

 
discard

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.