libpysal.cg.Grid

class libpysal.cg.Grid(bounds, resolution)[source]

Representation of a binning data structure.

Methods

add(self, item, pt)

Adds an item to the grid at a specified location.

bounds(self, bounds)

Returns a list of items found in the grid within the bounds specified.

in_grid(self, loc)

Returns whether a 2-tuple location _loc_ lies inside the grid bounds.

nearest(self, pt)

Returns the nearest item to a point.

proximity(self, pt, r)

Returns a list of items found in the grid within a specified distance of a point.

remove(self, item, pt)

Removes an item from the grid at a specified location.

__init__(self, bounds, resolution)[source]

Returns a grid with specified properties.

__init__(Rectangle, number) -> Grid

Parameters
boundsthe area for the grid to encompass
resolutionthe diameter of each bin

Examples

TODO: complete this doctest >>> g = Grid(Rectangle(0, 0, 10, 10), 1)

Methods

__init__(self, bounds, resolution)

Returns a grid with specified properties.

add(self, item, pt)

Adds an item to the grid at a specified location.

bounds(self, bounds)

Returns a list of items found in the grid within the bounds specified.

in_grid(self, loc)

Returns whether a 2-tuple location _loc_ lies inside the grid bounds.

nearest(self, pt)

Returns the nearest item to a point.

proximity(self, pt, r)

Returns a list of items found in the grid within a specified distance of a point.

remove(self, item, pt)

Removes an item from the grid at a specified location.