> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ST_Perimeter

This function calculates the 2D perimeter of a given geometry. It supports Polygon, MultiPolygon, and GeometryCollection geometries (as long as the GeometryCollection contains polygonal geometries). For other types, it returns 0. To measure lines, use [ST\_Length](/reference/wherobots-db/geometry-data/measurement/ST_Length).

To get the perimeter in meters, set `use_spheroid` to `true`. This calculates the geodesic perimeter using the WGS84 spheroid. When using `use_spheroid`, the `lenient` parameter defaults to true, assuming the geometry uses EPSG:4326. To throw an exception instead, set `lenient` to `false`.

<img src="https://mintcdn.com/wherobots/wLm_IRUSNlHZTHJP/images/sql-functions/ST_Perimeter/ST_Perimeter.svg?fit=max&auto=format&n=wLm_IRUSNlHZTHJP&q=85&s=c2cd10c03ea947d29b2fcdd6ba494475" alt="ST_Perimeter" width="500" height="300" data-path="images/sql-functions/ST_Perimeter/ST_Perimeter.svg" />

## Signatures

```sql theme={"system"}
ST_Perimeter(geom: Geometry)
```

```sql theme={"system"}
ST_Perimeter(geom: Geometry, use_spheroid: Boolean)
```

```sql theme={"system"}
ST_Perimeter(geom: Geometry, use_spheroid: Boolean, lenient: Boolean = True)
```

## Parameters

<ParamField body="geom" type="Geometry" required>
  The input geometry.
</ParamField>

<ParamField body="use_spheroid" type="Boolean">
  The use\_spheroid value.
</ParamField>

<ParamField body="lenient" type="Boolean" default="True">
  The lenient value.
</ParamField>

## Return type

<ResponseField type="Double">
  A numeric value.
</ResponseField>

## Examples

```sql theme={"system"}
SELECT ST_Perimeter(
        ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))')
)
```

```
20.0
```

```sql theme={"system"}
SELECT ST_Perimeter(
        ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))', 4326),
        true, false
)
```

```
2216860.5497177234
```
