title_wip

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

```
SELECT polygonsWithinSpherical([[[(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)]]]);
```

```
0
```

## readWKBMultiPolygon[​](#readwkbmultipolygon "Direct link to readWKBMultiPolygon")

Converts a WKB (Well Known Binary) MultiPolygon into a MultiPolygon type.

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

```
SELECT
    toTypeName(readWKBMultiPolygon(unhex('0106000000020000000103000000020000000500000000000000000000400000000000000000000000000000244000000000000000000000000000002440000000000000244000000000000000000000000000002440000000000000004000000000000000000500000000000000000010400000000000001040000000000000144000000000000010400000000000001440000000000000144000000000000010400000000000001440000000000000104000000000000010400103000000010000000400000000000000000024c000000000000024c000000000000024c000000000000022c000000000000022c0000000000000244000000000000024c000000000000024c0'))) AS type,
    readWKBMultiPolygon(unhex('0106000000020000000103000000020000000500000000000000000000400000000000000000000000000000244000000000000000000000000000002440000000000000244000000000000000000000000000002440000000000000004000000000000000000500000000000000000010400000000000001040000000000000144000000000000010400000000000001440000000000000144000000000000010400000000000001440000000000000104000000000000010400103000000010000000400000000000000000024c000000000000024c000000000000024c000000000000022c000000000000022c0000000000000244000000000000024c000000000000024c0')) AS output FORMAT Markdown
```

|  |  |  |  |
| --- | --- | --- | --- |
| type output|  |  | | --- | --- | | MultiPolygon [[[(2,0),(10,0),(10,10),(0,10),(2,0)],[(4,4),(5,4),(5,5),(4,5),(4,4)]],[[(-10,-10),(-10,-9),(-9,10),(-10,-10)]]] | | | |

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

String starting with `MULTIPOLYGON`

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

MultiPolygon

## readWKBPolygon[​](#readwkbpolygon "Direct link to readWKBPolygon")

Converts a WKB (Well Known Binary) MultiPolygon into a Polygon type.

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

```
SELECT
    toTypeName(readWKBPolygon(unhex('010300000001000000050000000000000000000040000000000000000000000000000024400000000000000000000000000000244000000000000024400000000000000000000000000000244000000000000000400000000000000000'))) AS type,
    readWKBPolygon(unhex('010300000001000000050000000000000000000040000000000000000000000000000024400000000000000000000000000000244000000000000024400000000000000000000000000000244000000000000000400000000000000000')) AS output
FORMAT Markdown
```

|  |  |  |  |
| --- | --- | --- | --- |
| type output|  |  | | --- | --- | | Polygon [[(2,0),(10,0),(10,10),(0,10),(2,0)]] | | | |

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

String starting with `POLYGON`

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

Polygon

## readWKBPoint[​](#readwkbpoint "Direct link to readWKBPoint")

The `readWKBPoint` function in ClickHouse parses a Well-Known Binary (WKB) representation of a Point geometry and returns a point in the internal ClickHouse format.

### Syntax[​](#syntax-4 "Direct link to Syntax")

```
readWKBPoint(wkb_string)
```

### Arguments[​](#arguments-4 "Direct link to Arguments")

- `wkb_string`: The input WKB string representing a Point geometry.

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

The function returns a ClickHouse internal representation of the Point geometry.

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

```
SELECT readWKBPoint(unhex('0101000000333333333333f33f3333333333330b40'));
```

```
(1.2,3.4)
```

## readWKBLineString[​](#readwkblinestring "Direct link to readWKBLineString")

Parses a Well-Known Binary (WKB) representation of a LineString geometry and returns it in the internal ClickHouse format.

### Syntax[​](#syntax-5 "Direct link to Syntax")

```
readWKBLineString(wkb_string)
```

### Arguments[​](#arguments-5 "Direct link to Arguments")

- `wkb_string`: The input WKB string representing a LineString geometry.

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

The function returns a ClickHouse internal representation of the linestring geometry.

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

```
SELECT readWKBLineString(unhex('010200000004000000000000000000f03f000000000000f03f0000000000000040000000000000004000000000000008400000000000000840000000000000f03f000000000000f03f'));
```

```
[(1,1),(2,2),(3,3),(1,1)]
```

## readWKBMultiLineString[​](#readwkbmultilinestring "Direct link to readWKBMultiLineString")

Parses a Well-Known Binary (WKB) representation of a MultiLineString geometry and returns it in the internal ClickHouse format.

### Syntax[​](#syntax-6 "Direct link to Syntax")

```
readWKBMultiLineString(wkb_string)
```

### Arguments[​](#arguments-6 "Direct link to Arguments")

- `wkb_string`: The input WKB string representing a MultiLineString geometry.

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

The function returns a ClickHouse internal representation of the multilinestring geometry.

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

```
SELECT readWKBMultiLineString(unhex('010500000002000000010200000003000000000000000000f03f000000000000f03f0000000000000040000000000000004000000000000008400000000000000840010200000003000000000000000000104000000000000010400000000000001440000000000000144000000000000018400000000000001840'));
```

```
[[(1,1),(2,2),(3,3)],[(4,4),(5,5),(6,6)]]
```

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

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

UInt8, 0 for false, 1 for true

## polygonsDistanceSpherical[​](#polygonsdistancespherical "Direct link to polygonsDistanceSpherical")

Calculates the minimal distance between two points where one point belongs to the first polygon and the second to another polygon. Spherical means that coordinates are interpreted as coordinates on a pure and ideal sphere, which is not true for the Earth. Using this type of coordinate system speeds up execution, but of course is not precise.

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

```
SELECT polygonsDistanceSpherical([[[(0, 0), (0, 0.1), (0.1, 0.1), (0.1, 0)]]], [[[(10., 10.), (10., 40.), (40., 40.), (40., 10.), (10., 10.)]]])
```

```
0.24372872211133834
```

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

Two polygons

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

Float64

## polygonsDistanceCartesian[​](#polygonsdistancecartesian "Direct link to polygonsDistanceCartesian")

Calculates distance between two polygons

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

```
SELECT polygonsDistanceCartesian([[[(0, 0), (0, 0.1), (0.1, 0.1), (0.1, 0)]]], [[[(10., 10.), (10., 40.), (40., 40.), (40., 10.), (10., 10.)]]])
```

```
14.000714267493642
```

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

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")