Functions / PostGIS / ST_Scroll
PostGISGeometry Editors

ST_Scroll

What is ST_Scroll?

ST_Scroll rotates the vertex ordering of a closed LineString so that it begins at the supplied point. The point must be an existing vertex of the line. Available since PostGIS 3.2.

SQL
ST_Scroll(geometry linestring, geometry point)geometry

The returned geometry has the same vertices and shape as the input — only the starting vertex changes. This affects how the ring is rendered directionally and how downstream operations that depend on vertex order (such as line-referenced measures) behave.

When would you use ST_Scroll?

Use ST_Scroll to normalize the starting vertex of administrative boundary rings or polygon outlines so that diffs, checksums, or visual comparisons across datasets match. It is also useful when a pipeline loop's canonical start should be a named valve location rather than whichever vertex happened to come first in source data.

In topology pipelines, consistent ring starts reduce noise in automated comparisons and make it easier to detect genuine geometric changes versus trivial re-orderings.

FAQs

Does the point argument have to be an existing vertex?

Yes. The supplied point must coincide exactly with one of the LineString's vertices — ST_Scroll does not snap or insert new points. Use ST_Snap or ST_AddPoint first if the desired start is off-vertex.

Does ST_Scroll work on open LineStrings?

No. The input must be a closed LineString (first and last vertex equal). Open lines have a natural start and end, so scrolling is undefined for them.

What version introduced ST_Scroll?

PostGIS 3.2. Earlier versions require a manual workaround using ST_DumpPoints and ST_MakeLine.

Does it change the geometry's shape or length?

No. Only vertex order changes. ST_Length, ST_Area, and ST_Equals all return identical results before and after scrolling.