libpysal
libpysal copied to clipboard
Weights for circle, spheres and other connected on borders
Hi, I wanted to know if there is a way of generating weights for circles, spheres and such in a way similar to
w=pysal.lat2W(3,1)?
This generates
w.full()
Out[62]: (array([[ 0., 1., 0.],
[ 1., 0., 1.],
[ 0., 1., 0.]]), [0, 1, 2])
But on a circle it should be
(array([[ 0., 1., 1.],
[ 1., 0., 1.],
[ 1., 1., 0.]]), [0, 1, 2])
Thanks!
Could I get assigned to this?
Sure! This'd be a real good way to get a head around how pysal works with and thinks about spatial relationships.
@ljwolf could I get some info on how that weight matrix came about?
@Algogator The lat2W function is really a helper function that defines the neighbor relations in a dictionary, and then passes that dict to the W class. So to do something similar for say, circles or spheres, one would come up with the function to define the neighbors, then use that as an argument for the constructor to get a W.
The circle case is a 1-dimensional wrapping of the row lattice to a torus. We have talked about adding a torus option to lat2w so perhaps this is something to consider?
@sjsrey torus=True/False like in R?
And would that be wrapping both the rows and columns?
Yes, wrapping in both row and columns.
Is this issue solved?if not can i try working on it?
@aghinsa it is still open if you would like to work on it. A PR would be welcome.
@aghinsa it is still open if you would like to work on it. A PR would be welcome.
hi @sjsrey... i just wanted to know if this issue is already taken? if not then i can work upon this issue...
another doubt...for rook=false what will be the the expected output for the corner point such as...
m = ps.lib.weights.lat2W(3,3,rook=False)
m.neighbors[2]
original output is [1, 5, 4]
@MgeeeeK The issue is still open and available.
For rook=False the queen definition applies. So location 2 is in the upper right corner of the lattice, 1 is to its left, 4 shares a vertex at the sw corner of cell 2, and cell 5 is directly below cell 2.
@MgeeeeK The issue is still open and available.
For
rook=Falsethe queen definition applies. So location 2 is in the upper right corner of the lattice, 1 is to its left, 4 shares a vertex at the sw corner of cell 2, and cell 5 is directly below cell 2.
Sorry if i was not clear before.... What i meant was...after wrapping rows and columns, what will be the upper right corner neighbor of 2