ST_Node
What is ST_Node?
ST_Node takes a linear geometry (typically a MULTILINESTRING) and splits every line at every intersection with another line, producing a "noded" MULTILINESTRING in which lines only meet at their endpoints. It is the standard preprocessing step for polygonisation and topology construction from raw line data.
ST_Node(geometry lines) → geometryThe output is a MULTILINESTRING whose vertices include every computed intersection point. Duplicate coincident portions are preserved as separate lines.
When would you use ST_Node?
Use ST_Node before ST_Polygonize to guarantee that polygons can be formed — unsnapped and unsplit lines are the most common reason polygonisation silently fails. It is also used when importing raw CAD or digitised line data to produce a clean network where every crossing becomes an explicit endpoint, enabling routing, graph analysis, or topology validation.
1-- Prepare a messy line layer for polygonisation
2WITH noded AS (
3 SELECT (ST_Dump(ST_Node(ST_Collect(geom)))).geom AS geom
4 FROM raw_lines
5)
6SELECT (ST_Dump(ST_Polygonize(geom))).geom AS poly
7FROM noded;FAQs
What is "noding"?
Noding a line set means splitting every line at every intersection with another line, so the resulting lines only touch at their endpoints. This is a prerequisite for many topology and polygon-construction algorithms.
Does ST_Node remove duplicate line segments?
No. It preserves duplicate coincident portions as separate features; if you want them merged, follow with ST_UnaryUnion or ST_LineMerge.
What input does it expect?
A linear geometry — LINESTRING or MULTILINESTRING. Collect your lines first with ST_Collect or ST_Union if you have many rows to node together.
Does it use a spatial index?
Not directly. It operates on a single noded geometry. To scale to very large line sets, partition the input by tile or region, node per partition, and then reconcile the edges.