libpysal.weights.
lat2SW
(nrows=3, ncols=5, criterion='rook', row_st=False)[source]¶Create a sparse W matrix 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. This method directly creates the W matrix using the strucuture of the contiguity type.
Examples
>>> from libpysal.weights import lat2W
>>> w9 = lat2SW(3,3)
>>> w9[0,1]
1
>>> w9[3,6]
1
>>> w9r = lat2SW(3,3, row_st=True)
>>> w9r[3,6] == 1./3
True