pysal.lib.weights.hexLat2W

pysal.lib.weights.hexLat2W(nrows=5, ncols=5)[source]

Create a W object for a hexagonal lattice.

Parameters:
nrows : int

number of rows

ncols : int

number of columns

Returns:
w : W

instance of spatial weights class W

Notes

Observations are row ordered: first k observations are in row 0, next k in row 1, and so on.

Construction is based on shifting every other column of a regular lattice down 1/2 of a cell.

Examples

>>> from pysal.lib.weights import lat2W
>>> w = lat2W()
>>> w.neighbors[1]
[0, 6, 2]
>>> w.neighbors[21]
[16, 20, 22]
>>> wh = hexLat2W()
>>> wh.neighbors[1]
[0, 6, 2, 5, 7]
>>> wh.neighbors[21]
[16, 20, 22]
>>>