1

I'm working with PostGIS 2.1.8. I need to split a polyline into as many straight segments this polyline contains. Here is an illustration to make it clear enough:

Polyline to segments

The initial feature is only one row and the query should produce a 4 rows result with attributes values being maintained and geometry column changed (I don't want to update length column):

# Initial table:

id   | name    | length   | the_geom
-----+---------+----------+-----------------
1    | Line 1  | 12.2     | 01000111100000


# Result table:

id   | name    | length   | the_geom
-----+---------+----------+-----------------
1    | Line 1  | 12.2     | 01000111100000
2    | Line 1  | 12.2     | 01001111000011
3    | Line 1  | 12.2     | 01000110010000
4    | Line 1  | 12.2     | 00000111100000

I have found the function st_subdivide() (see here) but it is available from PostGIS version 2.2... I can't upgrade my PostGIS version because I'm at work and not allowed to do it.

Any idea on how to achieve that with an older than 2.2 PostGIS version?

1
0

Thanks to @user30184 comment, I found the following solution:

SELECT
  id,
  name,
  length,
  the_geom

FROM (SELECT
  id,
  name,
  length,
  (st_dump(the_geom)).geom AS the_geom
);

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