libpysal icon indicating copy to clipboard operation
libpysal copied to clipboard

Weights for circle, spheres and other connected on borders

Open ozak opened this issue 8 years ago • 12 comments

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!

ozak avatar Dec 17 '16 06:12 ozak

Could I get assigned to this?

Algogator avatar Feb 25 '18 21:02 Algogator

Sure! This'd be a real good way to get a head around how pysal works with and thinks about spatial relationships.

ljwolf avatar Feb 26 '18 00:02 ljwolf

@ljwolf could I get some info on how that weight matrix came about?

Algogator avatar Mar 02 '18 16:03 Algogator

@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 avatar Mar 02 '18 17:03 sjsrey

@sjsrey torus=True/False like in R?

And would that be wrapping both the rows and columns?

Algogator avatar Mar 04 '18 02:03 Algogator

Yes, wrapping in both row and columns.

sjsrey avatar Mar 10 '18 16:03 sjsrey

Is this issue solved?if not can i try working on it?

aghinsa avatar Oct 07 '19 18:10 aghinsa

@aghinsa it is still open if you would like to work on it. A PR would be welcome.

sjsrey avatar Oct 15 '19 03:10 sjsrey

@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...

MgeeeeK avatar Feb 12 '20 15:02 MgeeeeK

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 avatar Feb 12 '20 15:02 MgeeeeK

@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.

sjsrey avatar Feb 12 '20 15:02 sjsrey

@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.

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

MgeeeeK avatar Feb 12 '20 16:02 MgeeeeK