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

> Documentation for Geometry Functions

# Functions for Working with Geometry

<h2 id="geometry">
  Geometry
</h2>

Geometry functions allow you to calculate perimeter and area for geometric types such as POLYGON, LINESTRING, MULTIPOLYGON, MULTILINESTRING, RING, and POINT. Use geometries in Geometry type. If the input value is `NULL`, all functions below will return 0.

<h2 id="perimetercartesian">
  perimeterCartesian
</h2>

Calculates the perimeter of the given Geometry object in the Cartesian (flat) coordinate system.

**Syntax**

```sql theme={null}
perimeterCartesian(geom)
```

**Arguments**

* `geom` — Geometry object. [Geometry](/reference/data-types/geo).

**Returned values**

* Number — Perimeter of the object in the coordinate system units. [Float64](/reference/data-types/float).

**Example**

```sql title="Query" theme={null}
CREATE TABLE IF NOT EXISTS geo_dst (geom Geometry) ENGINE = Memory();
INSERT INTO geo_dst SELECT readWKT('POLYGON((0 0,1 0,1 1,0 1,0 0))');
SELECT perimeterCartesian(geom) FROM geo_dst;
```

```response title="Response" theme={null}
┌─perimeterCartesian(geom)─┐
│ 4.0                      │
└──────────────────────────┘
```

<h2 id="areacartesian">
  areaCartesian
</h2>

Calculates the area of the given Geometry object in the Cartesian coordinate system.

**Syntax**

```sql theme={null}
areaCartesian(geom)
```

**Arguments**

* `geom` — Geometry object. [Geometry](/reference/data-types/geo).

**Returned values**

* Number — Area of the object in coordinate system units. [Float64](/reference/data-types/float).

**Example**

```sql title="Query" theme={null}
CREATE TABLE IF NOT EXISTS geo_dst (geom Geometry) ENGINE = Memory();
INSERT INTO geo_dst SELECT readWKT('POLYGON((0 0,1 0,1 1,0 1,0 0))');
SELECT areaCartesian(geom) FROM geo_dst;
```

```response title="Response" theme={null}
┌─areaCartesian(geom)─┐
│ -1                  │
└─────────────────────┘
```

<h2 id="perimeterspherical">
  perimeterSpherical
</h2>

Calculates the perimeter of a Geometry object on the surface of a sphere.

**Syntax**

```sql theme={null}
perimeterSpherical(geom)
```

**Arguments**

* `geom` — Geometry object. [Geometry](/reference/data-types/geo).

**Returned values**

* Number — Perimeter. [Float64](/reference/data-types/float).

**Example**

```sql title="Query" theme={null}
CREATE TABLE IF NOT EXISTS geo_dst (geom Geometry) ENGINE = Memory();
INSERT INTO geo_dst SELECT readWKT('LINESTRING(0 0,1 0,1 1,0 1,0 0)');
SELECT perimeterSpherical(geom) FROM geo_dst;
```

```response title="Response" theme={null}
┌─perimeterSpherical(geom)─┐
│ 0                        │
└──────────────────────────┘
```

<h2 id="areaspherical">
  areaSpherical
</h2>

Calculates the area of a Geometry object on the surface of a sphere.

**Syntax**

```sql theme={null}
areaSpherical(geom)
```

**Arguments**

* `geom` — Geometry. [Geometry](/reference/data-types/geo).

**Returned values**

* Number — Area. [Float64](/reference/data-types/float).

**Example**

```sql title="Query" theme={null}
CREATE TABLE IF NOT EXISTS geo_dst (geom Geometry) ENGINE = Memory();
INSERT INTO geo_dst SELECT readWKT('POLYGON((0 0,1 0,1 1,0 1,0 0))');
SELECT areaSpherical(geom) FROM geo_dst;
```

```response title="Response" theme={null}
┌─areaSpherical(geom)────┐
│ -0.0003046096848622019 │
└────────────────────────┘
```
