Skip to main content

nearestPoints

Finds the nearest points between geometry a and geometry b.

The returned points can be points along a line segment, not necessarily one of the vertices of the input geometries.

Parameters​

NameTypeDescription
aGeometry | Prepared<Geometry>First geometry
bGeometrySecond geometry

Returns​

[ Point, Point ]

An array with two point geometries, first is the nearest point from the geometry a second from the geometry b

Throws​

  • GEOSError on unsupported geometry types (curved)
  • GEOSError when either geometry is empty

See also​

  • distance computes the distance between two geometries
  • distanceWithin returns true when two geometries are within a given distance
  • prepare improves performance of repeated calls against a single geometry

Examples​

nearest points between point and line
nearest points between two polygons