Skip to main content

flipCoordinates

The flipCoordinates function swaps the coordinates of a point, ring, polygon, or multipolygon. This is useful, for example, when converting between coordinate systems where the order of latitude and longitude differs.

Input Parameters

  • coordinates — A tuple representing a point (x, y), or an array of such tuples representing a ring, polygon, or multipolygon. Supported input types include:
    • Point: A tuple (x, y) where x and y are Float64 values.
    • Ring: An array of points [(x1, y1), (x2, y2), ...].
    • Polygon: An array of rings [ring1, ring2, ...], where each ring is an array of points.
    • Multipolygon: An array of polygons [polygon1, polygon2, ...].

Returned Value

The function returns the input with the coordinates flipped. For example:
  • A point (x, y) becomes (y, x).
  • A ring [(x1, y1), (x2, y2)] becomes [(y1, x1), (y2, x2)].
  • Nested structures like polygons and multipolygons are processed recursively.

Examples

Example 1: Flipping a Single Point

Example 2: Flipping an Array of Points (Ring)

Example 3: Flipping a Polygon

Example 4: Flipping a Multipolygon

Last modified on July 2, 2026