> ## 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_LocalOutlierFactor

Computes the Local Outlier Factor (LOF) for each point in the input dataset.

Local Outlier Factor is an algorithm for determining the degree to which a single record is an inlier or outlier. It is
based on how close a record is to its `k` nearest neighbors vs how close those neighbors are to their `k` nearest
neighbors. Values substantially less than `1` imply that the record is an inlier, while values greater than `1` imply that
the record is an outlier.

<Note>
  ST\_LocalOutlierFactor has a useSphere parameter rather than a useSpheroid parameter. This function thus uses a spherical model of the earth rather than an ellipsoidal model when calculating distance.
</Note>

<img src="https://mintcdn.com/wherobots/fqh3gPDE0J25Lra_/images/sql-functions/ST_LocalOutlierFactor/ST_LocalOutlierFactor.svg?fit=max&auto=format&n=fqh3gPDE0J25Lra_&q=85&s=e7698db70f5ed02518eda3f655a8ef2f" alt="ST_LocalOutlierFactor" width="400" height="170" data-path="images/sql-functions/ST_LocalOutlierFactor/ST_LocalOutlierFactor.svg" />

## Signatures

```sql theme={"system"}
ST_LocalOutlierFactor(geometry: Geometry, k: Int, useSphere: Boolean)
```

## Parameters

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

<ParamField body="k" type="Integer" required>
  The k value.
</ParamField>

<ParamField body="useSphere" type="Boolean" required>
  The use sphere value.
</ParamField>

## Return type

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

## Example

```sql theme={"system"}
SELECT ST_LocalOutlierFactor(geometry, 5, true)
```

```
1.0009256283408587
```
