libpysal.weights.
nonplanar_neighbors
(w, geodataframe, tolerance=0.001)[source]¶Detect neighbors for non-planar polygon collections
Parameters: |
|
---|---|
Returns: |
|
Notes
This relaxes the notion of contiguity neighbors for the case of shapefiles that violate the condition of planar enforcement. It handles three types of conditions present in such files that would result in islands when using the regular PySAL contiguity methods. The first are edges for nearby polygons that should be shared, but are digitized separately for the individual polygons and the resulting edges do not coincide, but instead the edges intersect. The second case is similar to the first, only the resultant edges do not intersect but are “close”. The final case arises when one polygon is “inside” a second polygon but is not encoded to represent a hole in the containing polygon.
The buffering check assumes the geometry coordinates are projected.
References
Planar Enforcement: http://ibis.geog.ubc.ca/courses/klink/gis.notes/ncgia/u12.html#SEC12.6
Examples
>>> import geopandas as gpd
>>> import libpysal
>>> df = gpd.read_file(libpysal.examples.get_path('map_RS_BR.shp'))
>>> w = libpysal.weights.contiguity.Queen.from_dataframe(df)
>>> import libpysal
>>> w.islands
[0, 4, 23, 27, 80, 94, 101, 107, 109, 119, 122, 139, 169, 175, 223, 239, 247, 253, 254, 255, 256, 261, 276, 291, 294, 303, 321, 357, 374]
>>> wnp = libpysal.weights.util.nonplanar_neighbors(w, df)
>>> wnp.islands
[]
>>> w.neighbors[0]
[]
>>> wnp.neighbors[0]
[23, 59, 152, 239]
>>> wnp.neighbors[23]
[0, 45, 59, 107, 152, 185, 246]
>>>
Also see nonplanarweights.ipynb
Attributes: |
|
---|