libpysal.cg.PointLocator¶
- class libpysal.cg.PointLocator(points)[source]¶
An abstract representation of a point indexing data structure.
Create a point locator for a sequence of points.
Examples
>>> points = [Point((0, 0)), Point((1, 6)), Point((5.4, 1.4))] >>> pl = PointLocator(points)Methods
nearest(query_point)Returns the nearest point indexed to a query point.
overlapping(region_rect)Returns the indexed points located inside a rectangular query region.
polygon(polygon)Returns the indexed points located inside a polygon
proximity(origin, r)Returns the indexed points located within some distance of an origin point.
region(region_rect)Returns the indexed points located inside a rectangular query region.
- nearest(query_point)[source]¶
Returns the nearest point indexed to a query point.
nearest(Point) -> Point
Examples
>>> points = [Point((0, 0)), Point((1, 6)), Point((5.4, 1.4))] >>> pl = PointLocator(points) >>> n = pl.nearest(Point((1, 1))) >>> str(n) '(0.0, 0.0)'
- overlapping(region_rect)[source]¶
Returns the indexed points located inside a rectangular query region.
region(Rectangle) -> Point list
Examples
>>> points = [Point((0, 0)), Point((1, 6)), Point((5.4, 1.4))] >>> pl = PointLocator(points) >>> pts = pl.region(Rectangle(-1, -1, 10, 10)) >>> len(pts) 3
- proximity(origin, r)[source]¶
Returns the indexed points located within some distance of an origin point.
proximity(Point, number) -> Point list
- Parameters:¶
Examples
>>> points = [Point((0, 0)), Point((1, 6)), Point((5.4, 1.4))] >>> pl = PointLocator(points) >>> len(pl.proximity(Point((1, 0)), 2)) 1
- region(region_rect)[source]¶
Returns the indexed points located inside a rectangular query region.
region(Rectangle) -> Point list
Examples
>>> points = [Point((0, 0)), Point((1, 6)), Point((5.4, 1.4))] >>> pl = PointLocator(points) >>> pts = pl.region(Rectangle(-1, -1, 10, 10)) >>> len(pts) 3