3

My question follows from Splitting Streets to Create Polygons?

I was able to successfully convert a layer of linestrings to polygons based on line intersections with the query given in the answer.

SELECT (ST_Dump(ST_Polygonize(ST_Node(multi_geom)))).geom
FROM   (
  SELECT ST_Collect(<geom>) AS multi_geom
  FROM   <your_table>
  -- WHERE <condition>
  -- GROUP BY <attribute>
) q
;

However, I had a problem with ST_Collect and used ST_Union to create a single geometry of lines from the original linestrings. What I noticed was, St_Union is doing the same thing that St_Node does, St_Union creates a single geometry from lines splitting them at intersections. I simply call St_Dumps on the output from St_Union. This is the transformed query:

SELECT (ST_Dump(ST_Polygonize(q.geom))).geom geom FROM (SELECT ST_Union(geom) geom FROM streets

Are St_Union and St_Node (with regards to this specific operation) similar or is there any benefit from using one over the other?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
c00der
  • 231
  • 1
  • 8

0 Answers0