Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in Weights #59

Closed
sjsrey opened this issue Feb 19, 2013 · 3 comments
Closed

Bug in Weights #59

sjsrey opened this issue Feb 19, 2013 · 3 comments
Labels

Comments

@sjsrey
Copy link
Member

sjsrey commented Feb 19, 2013

Original author: schmi...@gmail.com (March 12, 2010 00:45:54)

Reported by David via Email,
Check this out...

Run the following lines in python on the attached shapefile... then look at it in a GIS... something is fishy.
import pysal
phx_shp = '38060.shp'
ws = []
shp = pysal.open(phx_shp, 'r')
ws.append(pysal.weights.ContiguityWeights.queen(phx_shp))
ws.append(pysal.weights.ContiguityWeights.rook(phx_shp))
ws[0].type='queen'
ws[1].type='rook'
print ws[0][363]
print ws[0][442]
print ws[0][477]
print ws[1][363]
print ws[1][442]
print ws[1][477]

All the troublemakers have something in common... but they're not islands.

-David

Original issue: http://code.google.com/p/pysal/issues/detail?id=59

@sjsrey
Copy link
Member Author

sjsrey commented Feb 19, 2013

From schmi...@gmail.com on March 12, 2010 00:54:00
The problem is with land locked polygons. These polygon's exists within holes of larger polygon's. Holes of
larger polygon's are currently ignored when building Contiguity based weights. The root problem lies in the
Polygon class, which does NOT include holes in the vertices list. Andrew and I had some back and forth on
this when the Polygon class was first built and I can't remember exactly why holes were excluded in the end.

We probably need to implement something similar to what mark is working on with GeoDa, a tree structure to
represent nested shapes. In the meantime, we need to determine if holes can be safely added to the vertices
list without breaking other code (like centroids). The documentation is also not explicit about what's included
in the verts list. Tests are needed too.

@sjsrey
Copy link
Member Author

sjsrey commented Feb 19, 2013

From schmi...@gmail.com on March 23, 2010 23:14:47
Added the Virginia Counties as an example dataset in PySAL. This file more obviously displays the bug than
Maricopa census tracts. Working on unit tests.

@sjsrey
Copy link
Member Author

sjsrey commented Feb 19, 2013

From schmi...@gmail.com on March 26, 2010 01:21:15
Changed line 885 in shapes.py,
from: return sum([part for part in self._vertices], [])
to: return sum([part for part in self._vertices], []) + sum([part for part in self._holes], [])

All unit tests still pass, but we may want to evaluate the Polygon API and make sure it works as expected in most
use cases.

@sjsrey sjsrey closed this as completed Feb 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant