Skip to content
🎉 Apache Sedona 1.8.1 is now available! Check out the new features and improvements.

ST_LocalOutlierFactor

Introduction: 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.

Format: ST_LocalOutlierFactor(geometry: Geometry, k: Int, useSphere: Boolean)

Since: v1.7.1

SQL Example

SELECT ST_LocalOutlierFactor(geometry, 5, true)

Output:

1.0009256283408587