PySAL Core Library (libpysal)

4.14.1 · active · verified Thu Apr 16

libpysal is the foundational package of the PySAL (Python Spatial Analysis Library) ecosystem. It provides core algorithms and data structures for spatial analysis, including computational geometry, spatial weights matrix creation, and access to built-in example datasets. It serves as a building block for many higher-level PySAL packages and is under active development, with frequent minor releases.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates loading a built-in geospatial dataset using `libpysal.examples`, then creating a Queen contiguity spatial weights matrix from a GeoDataFrame using `libpysal.weights`.

import libpysal
import geopandas as gpd
from libpysal.weights import Queen

# Load example dataset
url = libpysal.examples.get_path('columbus.shp')
gdf = gpd.read_file(url)

# Create queen contiguity weights
weights = Queen.from_dataframe(gdf)

# Print summary of weights
print(weights.summary())

view raw JSON →