connectivity

connectivity(
    data,
    w=None,
    *,
    method='queen',
    tiles='carto-positron',
    title=None,
    gdf=None,
    ref=None,
)

A map of the neighbour links of a set of weights, with the distribution of neighbours per unit.

Parameters

Name Type Description Default
data A scale id, a dataset id or a panel, or a GeoDataFrame with geo_id required
w The weights to draw (default: method weights built from the boundaries) None
method str The weights to build when w is not given (see weights) 'queen'
tiles str | None The basemap style (None: no basemap) 'carto-positron'
title str | None The figure title None
gdf Boundaries to use instead of the project’s None

Returns

Name Type Description
result object A result with .fig (the links over the map), .fig_hist (neighbours per unit), .df (one row per unit with its number of neighbours), the weights .w and .interpret().

Example

!pip install -q geo4bolivia
import geo4bolivia as geo

res = geo.connectivity("municipality")
print(res.interpret())
res.fig

The spatial weights graph (queen contiguity (1 island(s) attached to nearest neighbor), row-standardized, n=343) links 343 units with 5.52 neighbors each on average (ranging from 1 to 12); 1.61% of all possible unit pairs are connected, so each spatial lag averages over a small, local set of neighbors.

The graph forms a single connected component — every unit can reach every other through a chain of neighbors, which is what global spatial statistics (Moran’s I, spatial models) implicitly assume.

1 unit(s) initially had no neighbors at all (islands: BO-05-10-02). Islands receive an undefined spatial lag, so the weights builder attaches them to their nearest neighbor by default.

Cardinalities are quite uneven (from 1 to 12 neighbors): densely connected units get smoother, more averaged lags than sparsely connected ones — worth keeping in mind when comparing local statistics.

These are associations, not causal effects. A causal reading needs a research design.