libpysal.weights.
attach_islands
(w, w_knn1, **kwargs)[source]¶Attach nearest neighbor to islands in spatial weight w.
pysal spatial weight object (unstandardized).
Nearest neighbor pysal spatial weight object (k=1).
optional arguments for pysal.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}