title_wip

Two polygons

### Returned value[​](#returned-value-13 "Direct link to Returned value")

Float64

## polygonsEqualsCartesian[​](#polygonsequalscartesian "Direct link to polygonsEqualsCartesian")

Returns true if two polygons are equal

### Example[​](#example-14 "Direct link to Example")

```
SELECT polygonsEqualsCartesian([[[(1., 1.), (1., 4.), (4., 4.), (4., 1.)]]], [[[(1., 1.), (1., 4.), (4., 4.), (4., 1.), (1., 1.)]]])
```

```
1
```

### Input parameters[​](#input-parameters-7 "Direct link to Input parameters")

Two polygons

### Returned value[​](#returned-value-14 "Direct link to Returned value")

UInt8, 0 for false, 1 for true

## polygonsSymDifferenceSpherical[​](#polygonssymdifferencespherical "Direct link to polygonsSymDifferenceSpherical")

Calculates the spatial set theoretic symmetric difference (XOR) between two polygons

### Example[​](#example-15 "Direct link to Example")

```
SELECT wkt(arraySort(polygonsSymDifferenceSpherical([[(50., 50.), (50., -50.), (-50., -50.), (-50., 50.), (50., 50.)], [(10., 10.), (10., 40.), (40., 40.), (40., 10.), (10., 10.)], [(-10., -10.), (-10., -40.), (-40., -40.), (-40., -10.), (-10., -10.)]], [[(-20., -20.), (-20., 20.), (20., 20.), (20., -20.), (-20., -20.)]])));
```

```
MULTIPOLYGON(((-20 -10.3067,-10 -10,-10 -20.8791,-20 -20,-20 -10.3067)),((10 20.8791,20 20,20 10.3067,10 10,10 20.8791)),((50 50,50 -50,-50 -50,-50 50,50 50),(20 10.3067,40 10,40 40,10 40,10 20.8791,-20 20,-20 -10.3067,-40 -10,-40 -40,-10 -40,-10 -20.8791,20 -20,20 10.3067)))
```

### Input parameters[​](#input-parameters-8 "Direct link to Input parameters")

Polygons

### Returned value[​](#returned-value-15 "Direct link to Returned value")

MultiPolygon

## polygonsSymDifferenceCartesian[​](#polygonssymdifferencecartesian "Direct link to polygonsSymDifferenceCartesian")

The same as `polygonsSymDifferenceSpherical`, but the coordinates are in the Cartesian coordinate system; which is more close to the model of the real Earth.

### Example[​](#example-16 "Direct link to Example")

```
SELECT wkt(polygonsSymDifferenceCartesian([[[(0, 0), (0, 3), (1, 2.9), (2, 2.6), (2.6, 2), (2.9, 1), (3, 0), (0, 0)]]], [[[(1., 1.), (1., 4.), (4., 4.), (4., 1.), (1., 1.)]]]))
```

```
MULTIPOLYGON(((1 2.9,1 1,2.9 1,3 0,0 0,0 3,1 2.9)),((1 2.9,1 4,4 4,4 1,2.9 1,2.6 2,2 2.6,1 2.9)))
```

### Input parameters[​](#input-parameters-9 "Direct link to Input parameters")

Polygons

### Returned value[​](#returned-value-16 "Direct link to Returned value")

MultiPolygon

## polygonsIntersectionSpherical[​](#polygonsintersectionspherical "Direct link to polygonsIntersectionSpherical")

Calculates the intersection (AND) between polygons, coordinates are spherical.

### Example[​](#example-17 "Direct link to Example")

```
SELECT wkt(arrayMap(a -> arrayMap(b -> arrayMap(c -> (round(c.1, 6), round(c.2, 6)), b), a), polygonsIntersectionSpherical([[[(4.3613577, 50.8651821), (4.349556, 50.8535879), (4.3602419, 50.8435626), (4.3830299, 50.8428851), (4.3904543, 50.8564867), (4.3613148, 50.8651279)]]], [[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]])))
```

```
MULTIPOLYGON(((4.3666 50.8434,4.36024 50.8436,4.34956 50.8536,4.35268 50.8567,4.36794 50.8525,4.3666 50.8434)))
```

### Input parameters[​](#input-parameters-10 "Direct link to Input parameters")

Polygons

### Returned value[​](#returned-value-17 "Direct link to Returned value")

MultiPolygon

## polygonsWithinCartesian[​](#polygonswithincartesian "Direct link to polygonsWithinCartesian")

Returns true if the second polygon is within the first polygon.

### Example[​](#example-18 "Direct link to Example")

```
SELECT polygonsWithinCartesian([[[(2., 2.), (2., 3.), (3., 3.), (3., 2.)]]], [[[(1., 1.), (1., 4.), (4., 4.), (4., 1.), (1., 1.)]]])
```

```
1
```

### Input parameters[​](#input-parameters-11 "Direct link to Input parameters")

Two polygons

### Returned value[​](#returned-value-18 "Direct link to Returned value")

UInt8, 0 for false, 1 for true

## polygonsIntersectCartesian[​](#polygonsintersectcartesian "Direct link to polygonsIntersectCartesian")

Returns true if the two polygons intersect (share any common area or boundary).

### Example[​](#example-intersects-cartesian "Direct link to Example")

```
SELECT polygonsIntersectCartesian([[[(2., 2.), (2., 3.), (3., 3.), (3., 2.)]]], [[[(1., 1.), (1., 4.), (4., 4.), (4., 1.), (1., 1.)]]])
```

```
1
```

### Input parameters[​](#input-parameters-intersects-cartesian "Direct link to Input parameters")

Two polygons

### Returned value[​](#returned-value-intersects-cartesian "Direct link to Returned value")

UInt8, 0 for false, 1 for true

## polygonsIntersectSpherical[​](#polygonsintersectspherical "Direct link to polygonsIntersectSpherical")

Returns true if the two polygons intersect (share any common area or boundary). Reference <https://www.boost.org/doc/libs/1_62_0/libs/geometry/doc/html/geometry/reference/algorithms/intersects.html>

### Example[​](#example-intersects-spherical "Direct link to Example")

```
SELECT polygonsIntersectSpherical([[[(4.3613577, 50.8651821), (4.349556, 50.8535879), (4.3602419, 50.8435626), (4.3830299, 50.8428851), (4.3904543, 50.8564867), (4.3613148, 50.8651279)]]], [[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]]);
```

```
1
```

### Input parameters[​](#input-parameters-intersects-spherical "Direct link to Input parameters")

Two polygons

### Returned value[​](#returned-value-intersects-spherical "Direct link to Returned value")

UInt8, 0 for false, 1 for true

## polygonConvexHullCartesian[​](#polygonconvexhullcartesian "Direct link to polygonConvexHullCartesian")

Calculates a convex hull. [Reference](https://www.boost.org/doc/libs/1_61_0/libs/geometry/doc/html/geometry/reference/algorithms/convex_hull.html)

Coordinates are in Cartesian coordinate system.

### Example[​](#example-19 "Direct link to Example")

```
SELECT wkt(polygonConvexHullCartesian([[[(0., 0.), (0., 5.), (5., 5.), (5., 0.), (2., 3.)]]]))
```

```
POLYGON((0 0,0 5,5 5,5 0,0 0))
```

### Input parameters[​](#input-parameters-12 "Direct link to Input parameters")

MultiPolygon

### Returned value[​](#returned-value-19 "Direct link to Returned value")

Polygon

## polygonAreaSpherical[​](#polygonareaspherical "Direct link to polygonAreaSpherical")

Calculates the surface area of a polygon.

### Example[​](#example-20 "Direct link to Example")

```
SELECT round(polygonAreaSpherical([[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]]), 14)
```

```
9.387704e-8
```

### Input parameters[​](#input-parameters-13 "Direct link to Input parameters")

Polygon

### Returned value[​](#returned-value-20 "Direct link to Returned value")

Float

## polygonsUnionSpherical[​](#polygonsunionspherical "Direct link to polygonsUnionSpherical")

Calculates a union (OR).

### Example[​](#example-21 "Direct link to Example")

```
SELECT wkt(polygonsUnionSpherical([[[(4.3613577, 50.8651821), (4.349556, 50.8535879), (4.3602419, 50.8435626), (4.3830299, 50.8428851), (4.3904543, 50.8564867), (4.3613148, 50.8651279)]]], [[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]]))
```

```
MULTIPOLYGON(((4.36661 50.8434,4.36623 50.8408,4.34496 50.8333,4.33807 50.8487,4.34669 50.8583,4.35268 50.8567,4.36136 50.8652,4.36131 50.8651,4.39045 50.8565,4.38303 50.8429,4.36661 50.8434)))
```

### Input parameters[​](#input-parameters-14 "Direct link to Input parameters")

Polygons

### Returned value[​](#returned-value-21 "Direct link to Returned value")

MultiPolygon

## polygonPerimeterSpherical[​](#polygonperimeterspherical "Direct link to polygonPerimeterSpherical")

Calculates the perimeter of the polygon.

### Example[​](#example-22 "Direct link to Example")

#### Polygon representing Zimbabwe[​](#polygon-representing-zimbabwe "Direct link to Polygon representing Zimbabwe")