How to do it...

In order to perform the basic skeletonization, we'll calculate the Voronoi polygons on the nodes that make up the original stream polygon. By default, the edges of the Voronoi polygons find the line that demarcates the midpoint between points. We will leverage this tendency by treating our lines like points—adding extra points to the lines and then converting the lines to a point set. This approach, in combination with the Voronoi approach, will provide an initial estimate of the polygon's centerline.

We will add extra points to our input geometries using the ST_Segmentize function and then convert the geometries to points using ST_DumpPoints:

CREATE TABLE chp06.voronoi_points AS(
  SELECT (ST_DumpPoints(ST_Segmentize(the_geom, ...

Get PostGIS Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.