Functions / PostGIS / ST_WrapX
PostGISGeometry Editors

ST_WrapX

What is ST_WrapX?

ST_WrapX splits a geometry at the specified wrap X value and moves all parts beyond that value by a supplied offset. It generalises ST_ShiftLongitude to arbitrary wrap longitudes.

SQL
ST_WrapX(geometry geom, float wrap, float move)geometry

wrap is the longitude at which the geometry is split; move is the distance to shift the wrapped portion (typically ±360). Available from PostGIS 2.3.

When would you use ST_WrapX?

Use ST_WrapX to produce Pacific-centred maps where you want longitudes centred on 180° rather than 0°. For example, call ST_WrapX(geom, 0, 360) to move the western hemisphere east, producing a 0..360 extent.

It is also useful for datasets published across custom wrap conventions — some oceanographic and climate datasets use 20°E as the wrap longitude, which a one-shot ST_WrapX call can normalise.

FAQs

How does ST_WrapX differ from ST_ShiftLongitude?

ST_ShiftLongitude only swaps between -180..180 and 0..360. ST_WrapX accepts any wrap value and move distance, making it the general-purpose choice for non-standard wrap conventions.

Does it split geometry that crosses the wrap value?

Yes. Crossing features are split at wrap and the portion past the wrap is translated by move in the X direction.

What SRID does it assume?

ST_WrapX works on any SRID — it only edits X values. It is most meaningful for geographic CRSs where X is longitude.

What version introduced ST_WrapX?

PostGIS 2.3.