momepy.sw_high#

momepy.sw_high(k, gdf=None, weights=None, ids=None, contiguity='queen', silent=True)[source]#

Generate spatial weights based on Queen or Rook contiguity of order k. All features within <= k steps are adjacent. Pass in either gdf or weights. If both are passed, weights is used. If weights are passed, contiguity is ignored and high order spatial weights based on weights are computed.

Parameters
kint

The order of contiguity.

gdfGeoDataFrame

A GeoDataFrame containing objects to analyse. Index has to be a consecutive range 0:x. Otherwise, spatial weights will not match objects.

weightslibpysal.weights

A libpysal.weights of order 1.

contiguitystr (default ‘queen’)

The type of contiguity weights. Can be 'queen' or 'rook'.

silentbool (default True)

Silence libpysal islands warnings (True).

Returns
libpysal.weights

The libpysal.weights object.

Examples

>>> first_order = libpysal.weights.Queen.from_dataframe(geodataframe)
>>> first_order.mean_neighbors
5.848032564450475
>>> fourth_order = sw_high(k=4, gdf=geodataframe)
>>> fourth.mean_neighbors
85.73188602442333