-
-
Save caiohamamura/d53c77887df137159d800701adc7cdf2 to your computer and use it in GitHub Desktop.
Convert a Linestring into a set of two-point segments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE lines ( | |
| gid integer primary key, | |
| geom geometry(Linestring, 4326) | |
| ); | |
| INSERT INTO lines VALUES (1, 'SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)'); | |
| INSERT INTO lines VALUES (2, 'SRID=4326;LINESTRING(0 1, 0 2, 0 3, 0 4)'); | |
| SELECT ST_AsText((ST_Dump(ST_Split(lines.geom, points.geom))).geom) | |
| FROM | |
| ( | |
| SELECT ST_Union(pt) geom FROM ( | |
| SELECT gid, geom, (ST_DumpPoints(geom)).geom AS pt FROM lines) a | |
| ) points, | |
| lines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment