libpysal.weights.attach_islands

libpysal.weights.attach_islands(w, w_knn1, **kwargs)[source]

Attach nearest neighbor to islands in spatial weight w.

Parameters:
wlibpysal.weights.W

pysal spatial weight object (unstandardized).

w_knn1libpysal.weights.W

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

**kwargskeyword arguments

optional arguments for pysal.weights.W

Returns:
: libpysal.weights.W

pysal spatial weight object w without islands.

Examples

>>> from libpysal.weights import lat2W, Rook, KNN, attach_islands
>>> import libpysal
>>> w = Rook.from_shapefile(libpysal.examples.get_path('10740.shp'))
>>> w.islands
[163]
>>> w_knn1 = KNN.from_shapefile(libpysal.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}