explore_connectivity_map
explore_connectivity_map(
gdf,
*,
w=None,
entity=None,
tiles='carto-positron',
title=None,
)Draw the spatial weights graph over the map and summarize its connectivity.
The figure overlays the neighbor graph (edges between adjacent centroids, one node per unit) on a light-grey polygon layer, and the companion histogram shows the neighbor-cardinality distribution — the standard visual audit of a W before any spatial statistic is computed on it.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| gdf | gpd.GeoDataFrame | Geometry frame (see :func:geometrics.read_gdf). |
required |
| w | W | None | libpysal weights aligned to the gdf entity ids. None builds the default weights (queen contiguity for polygons, 6-nearest-neighbor otherwise) with a :class:~geometrics.GeometricsWarning. |
None |
| entity | str | None | Entity id column of gdf; resolved automatically when None. |
None |
| tiles | str | None | MapLibre basemap style (e.g. "carto-positron"). None draws a vector (tile-free) figure suitable for deterministic PNG export. |
'carto-positron' |
| title | str | None | Figure title (a default naming the weights is used when None). |
None |
Returns
| Name | Type | Description |
|---|---|---|
| ConnectivityMapResult | The per-entity neighbor-cardinality frame, the graph figure (fig), the cardinality histogram (fig_hist), the connectivity scalars and w_spec. |
Examples
Connectivity of a two-cell map (each unit has exactly one neighbor):
import geopandas as gpd
from shapely.geometry import box
from geometrics.weights import explore_connectivity_map, make_weights
gdf = gpd.GeoDataFrame(
{"region": ["A", "B"]},
geometry=[box(0, 0, 1, 1), box(1, 0, 2, 1)],
crs="EPSG:4326",
)
res = explore_connectivity_map(gdf, w=make_weights(gdf), tiles=None)
(res.n_units, res.mean_neighbors)