Skip to content

pygeo.is_on_polygon_boundary

Daniel Flassig edited this page Jul 27, 2026 · 2 revisions

Tests whether a 2D point lies on the boundary of a polygon loop within a given tolerance.

The point is tested against the polygon points and edges. If its distance to a polygon point or edge is within the tolerance, the kind of contact and the number of that point or edge are returned. For an exact inside/outside decision use pygeo.is_in_polygon.

pygeo.is_on_polygon_boundary(point, polygon, tolerance)
Parameter Type Description
point {u,v} The test point in 2D.
polygon {{u,v}, ...} Coordinates of the polygon loop points in 2D. The loop is treated as closed.
tolerance number Maximum spatial distance to the boundary.

Return value

Type Description
type string
index integer

Notes:

  • The input is a single loop only.
  • Edges are numbered like their start point: edge i runs from point i to point i + 1, and the last edge closes the loop from the last point back to point 1.
  • Resting on a polygon point takes precedence: if the point is within the tolerance of both a polygon point and an edge, "point" is returned.
  • If several polygon points or edges are within the tolerance, the nearest one is reported.
  • The loop orientation does not affect the result.

Example:

local polygon = {{0, 0}, {10, 0}, {10, 10}, {0, 10}}

local kind, index = pygeo.is_on_polygon_boundary({10, 5}, polygon, 0.001)
-- kind -> "edge", index -> 2 (the edge from {10,0} to {10,10})

local kind, index = pygeo.is_on_polygon_boundary({10, 10}, polygon, 0.001)
-- kind -> "point", index -> 3

local kind = pygeo.is_on_polygon_boundary({5, 5}, polygon, 0.001)
-- kind -> nil

Version Support:

Minimum PYTHA Version: V26

See also:

pygeo, pygeo.is_in_polygon

Clone this wiki locally