pysal.explore.spaghetti.snap_points_on_segments(points, segments)[source]

Place points onto closet segment in a set of segments

points : dict

Point id as key and (x,y) coordinate as value

segments : list

Elements are of type ** Note ** each element is a segment represented as a chain with one head and one tail node in other words one link only.

p2s : dict

key [point id (see points in arguments)]; value [a 2-tuple ((head, tail), point) where (head, tail) is the target segment, and point is the snapped location on the segment.


>>> import pysal.explore.spaghetti as spgh
>>> from import Point, Chain
>>> points = {0: Point((1,1))}
>>> segments = [Chain([Point((0,0)), Point((2,0))])]
>>> spgh.util.snap_points_on_segments(points, segments)
{0: ([(0.0, 0.0), (2.0, 0.0)], array([1., 0.]))}