PostGISGeometry Editors

ST_ShiftLongitude

What is ST_ShiftLongitude?

ST_ShiftLongitude rewrites X coordinates (interpreted as longitudes) so they fall in the 0..360 range if they were in -180..180, or vice versa. Only the X ordinate is affected.

SQL
ST_ShiftLongitude(geometry geom)geometry

The function is intended specifically for WGS84 longitudinal data straddling the antimeridian.

When would you use ST_ShiftLongitude?

Use ST_ShiftLongitude when working with features crossing the 180° meridian — for instance, the Aleutian Islands, Fiji, or a Pacific-basin exclusive economic zone. Shifting to 0..360 produces contiguous geometry that does not split visually at the dateline.

It is also a helpful quick fix for datasets published in 0..360 longitude that need to be normalised to the conventional -180..180 range before being consumed by web map clients.

FAQs

Does ST_ShiftLongitude change SRID?

No. Only X values are rewritten; SRID and all other ordinates remain unchanged.

Is it safe to call on non-WGS84 data?

It is permitted but rarely meaningful outside geographic CRSs. For projected data, longitudes are not expressed as X anyway.

How does ST_ShiftLongitude relate to ST_WrapX?

ST_WrapX is the more general and modern equivalent — it accepts a wrap longitude and move amount. ST_ShiftLongitude is the legacy shortcut for the common 180°/0° case.

Does it split geometry at the antimeridian?

No. It only moves coordinates. Splitting requires ST_Split or a custom approach with ST_Difference against a dateline line.