> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Documentation for flipCoordinates

# Flipping Coordinates

<h2 id="flipcoordinates">
  flipCoordinates
</h2>

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.

```sql theme={null}
flipCoordinates(coordinates)
```

<h3 id="input-parameters">
  Input Parameters
</h3>

* `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**](/reference/data-types/geo#point): A tuple `(x, y)` where `x` and `y` are [Float64](/reference/data-types/float) values.
  * [**Ring**](/reference/data-types/geo#ring): An array of points `[(x1, y1), (x2, y2), ...]`.
  * [**Polygon**](/reference/data-types/geo#polygon): An array of rings `[ring1, ring2, ...]`, where each ring is an array of points.
  * [**Multipolygon**](/reference/data-types/geo#multipolygon): An array of polygons `[polygon1, polygon2, ...]`.

<h3 id="returned-value">
  Returned Value
</h3>

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.

<h3 id="examples">
  Examples
</h3>

<h4 id="example-1">
  Example 1: Flipping a Single Point
</h4>

```sql theme={null}
SELECT flipCoordinates((10, 20)) AS flipped_point
```

```text theme={null}
┌─flipped_point─┐
│ (20,10)       │
└───────────────┘
```

<h4 id="example-2">
  Example 2: Flipping an Array of Points (Ring)
</h4>

```sql theme={null}
SELECT flipCoordinates([(10, 20), (30, 40)]) AS flipped_ring
```

```text theme={null}
┌─flipped_ring──────────────┐
│ [(20,10),(40,30)]         │
└───────────────────────────┘
```

<h4 id="example-3">
  Example 3: Flipping a Polygon
</h4>

```sql theme={null}
SELECT flipCoordinates([[(10, 20), (30, 40)], [(50, 60), (70, 80)]]) AS flipped_polygon
```

```text theme={null}
┌─flipped_polygon──────────────────────────────┐
│ [[(20,10),(40,30)],[(60,50),(80,70)]]        │
└──────────────────────────────────────────────┘
```

<h4 id="example-4">
  Example 4: Flipping a Multipolygon
</h4>

```sql theme={null}
SELECT flipCoordinates([[[10, 20], [30, 40]], [[50, 60], [70, 80]]]) AS flipped_multipolygon
```

```text theme={null}
┌─flipped_multipolygon──────────────────────────────┐
│ [[[20,10],[40,30]],[[60,50],[80,70]]]             │
└───────────────────────────────────────────────────┘
```
