pysal.explore.spaghetti.squared_distance_point_segment

pysal.explore.spaghetti.squared_distance_point_segment(point, segment)[source]

Find the squared distance between a point and a segment.

Parameters:
point : tuple

point coordinates (x,y)

segment : list

List of 2 point coordinate tuples [(x0,y0), (x1,y1)].

Returns:
sqd : float

distance squared between point and segment

nearp : numpy.ndarray

array of (xb, yb); the nearest point on the segment

Examples

>>> import pysal.explore.spaghetti as spgh
>>> point, segment = (1,1), ((0,0), (2,0))
>>> spgh.util.squared_distance_point_segment(point, segment)
(1.0, array([1., 0.]))