libpysal.weights.
lat2W
(nrows=5, ncols=5, rook=True, id_type='int', **kwargs)[source]¶Create a W object for a regular lattice.
Parameters: |
|
---|---|
Returns: |
|
Notes
Observations are row ordered: first k observations are in row 0, next k in row 1, and so on.
Examples
>>> from libpysal.weights import lat2W
>>> w9 = lat2W(3,3)
>>> "%.3f"%w9.pct_nonzero
'29.630'
>>> w9[0] == {1: 1.0, 3: 1.0}
True
>>> w9[3] == {0: 1.0, 4: 1.0, 6: 1.0}
True