libpysal.cg.PointLocator¶
-
class
libpysal.cg.
PointLocator
(points)[source]¶ An abstract representation of a point indexing data structure.
-
__init__
(self, points)[source]¶ Returns a point locator object.
__init__(Point list) -> PointLocator
- Parameters
- points
a
python:list
of
points
to
index
- points
Examples
>>> points = [Point((0, 0)), Point((1, 6)), Point((5.4, 1.4))] >>> pl = PointLocator(points)
Methods
__init__
(self, points)Returns a point locator object.
nearest
(self, query_point)Returns the nearest point indexed to a query point.
overlapping
(self, region_rect)Returns the indexed points located inside a rectangular query region.
polygon
(self, polygon)Returns the indexed points located inside a polygon
proximity
(self, origin, r)Returns the indexed points located within some distance of an origin point.
region
(self, region_rect)Returns the indexed points located inside a rectangular query region.
-
nearest
(self, query_point)[source]¶ Returns the nearest point indexed to a query point.
nearest(Point) -> Point
- Parameters
- query_point
a
point
to
find
the
nearest
indexed
point
to
- query_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
(self, region_rect)¶ Returns the indexed points located inside a rectangular query region.
region(Rectangle) -> Point list
- Parameters
- region_rect
the
rectangular
range
to
find
indexed
points
in
- region_rect
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
(self, origin, r)[source]¶ Returns the indexed points located within some distance of an origin point.
proximity(Point, number) -> Point list
- Parameters
- origin
the
point
to
find
indexed
points
near
- r
the
maximum
distance
to
find
indexed
point
from
the
origin
point
- origin
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
(self, region_rect)[source]¶ Returns the indexed points located inside a rectangular query region.
region(Rectangle) -> Point list
- Parameters
- region_rect
the
rectangular
range
to
find
indexed
points
in
- region_rect
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
-