Skip to main content

nearest

Returns the geometry with the minimum distance to the query geometry.

Cartesian distance is calculated between the actual geometries, not their bounding boxes.

If there are multiple equidistant geometries, this function will return only one of them. To return all such geometries, use nearestAll.

Parameters

NameTypeDescription
geometryGeometryGeometry for which the nearest neighbor is queried

Returns

G | undefined

The nearest geometry or undefined if the tree is empty

Throws

  • GEOSError if any of the considered candidates for the nearest geometry is one of unsupported geometry types (curved)

Examples