pysal.lib.weights.attach_islands

pysal.lib.weights.attach_islands(w, w_knn1)[source]

Attach nearest neighbor to islands in spatial weight w.

Parameters:
w : pysal.lib.weights.W

pysal spatial weight object (unstandardized).

w_knn1 : pysal.lib.weights.W

Nearest neighbor pysal spatial weight object (k=1).

Returns:
: pysal.lib.weights.W

pysal spatial weight object w without islands.

Examples

>>> from pysal.lib.weights import lat2W
>>> import pysal.lib
>>> w = pysal.lib.weights.contiguity.Rook.from_shapefile(pysal.lib.examples.get_path('10740.shp'))
>>> w.islands
[163]
>>> w_knn1 = pysal.lib.weights.distance.KNN.from_shapefile(pysal.lib.examples.get_path('10740.shp'),k=1)
>>> w_attach = attach_islands(w, w_knn1)
>>> w_attach.islands
[]
>>> w_attach[w.islands[0]]
{166: 1.0}