libpysal.cg.get_polygon_point_dist

libpysal.cg.get_polygon_point_dist(poly, pt)[source]

Returns the distance between a polygon and point.

Parameters:
polylibpysal.cg.Polygon

A polygon to compute distance from.

ptlibpysal.cg.Point

a point to compute distance from

Returns:
distfloat

The distance between poly and point.

Examples

>>> poly = Polygon([Point((0, 0)), Point((1, 0)), Point((1, 1)), Point((0, 1))])
>>> pt = Point((2, 0.5))
>>> get_polygon_point_dist(poly, pt)
1.0
>>> pt2 = Point((0.5, 0.5))
>>> get_polygon_point_dist(poly, pt2)
0.0