spopt
Spatial Optimization in PySAL
Decision gist · record as of 2026-08-14
Yes. Spopt is actively maintained, has no known vulnerabilities, installs with low friction, and fills a specific niche in spatial optimization that is not easily replicated by combining other packages. Install it if you are solving regionalization, facility location, or network-based optimization problems on geographic data; skip it if your work is purely aspatial or does not require constraint-based optimization.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.11 or later; pulp solver backend needs an external optimization engine (CBC is included by default).
- Low friction installation with a pure-Python wheel.
- Actively maintained as of July 2026 with a stable release cycle; 13 runtime dependencies are all mature, widely-used scientific libraries.
License · maintenance · safety
BSD 3-Clause (permissive) — BSD 3-Clause is permissive; you may use, modify, and distribute spopt freely in commercial or proprietary projects provided you retain the license notice.
last release 2025-07-14 (396 days) · last repo commit 2026-07-07 · 380 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 102,102 downloads/mo, #12,891 on PyPI
Alternatives
Verify before relying
pip install spopt
import spopt
import geopandas
import libpysal
import numpy
mexico = geopandas.read_file(libpysal.examples.get_path("mexicojoin.shp"))
w = libpysal.weights.Queen.from_dataframe(mexico)
model = spopt.region.MaxPHeuristic(mexico, w, ["PCGDP1950"], "count", 4, 2)
model.solve()
mexico["regions"] = model.labels_- Performance characteristics and scalability limits for large geographic datasets are not quantified in the fact sheet.
- Whether the package supports alternative solvers beyond pulp's default CBC backend.
What it is and what it does
Spopt is a Python library for solving spatial optimization problems on geographic data, originating from PySAL's region module and now actively developed as a standalone package. It handles three main problem classes: regionalization (grouping geographic units into contiguous regions under constraints), facility location (siting facilities to serve demand across a network), and transportation-oriented modeling. The library integrates tightly with geopandas for spatial data handling, libpysal for spatial weights and connectivity, and pulp for constraint programming, allowing you to define optimization objectives and constraints over geographic features.
Typical workflows involve loading geographic data as GeoDataFrames, defining spatial relationships through weights matrices, and instantiating a model class (like MaxPHeuristic for regionalization or MCLP for facility location) with your data and parameters. The library handles the translation to an optimization problem, solves it via an external solver, and returns region assignments or facility locations as labels you can map back to your original data. It's designed for researchers and practitioners working with spatial planning, urban design, or resource allocation problems where geography and adjacency constraints matter.
Use it for
- Partition a country into regions for administrative planning or data collection while respecting population thresholds and geographic contiguity.
- Locate emergency service facilities (hospitals, fire stations) to maximize coverage of demand points across a street network.
- Group census tracts or neighborhoods into homogeneous clusters for analysis while maintaining spatial connectivity.
- Solve max-p-regions problems to find the minimum number of regions that satisfy a population or attribute threshold.
- Model transportation networks to optimize routing or service delivery under distance and capacity constraints.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Spopt is actively maintained, has no known vulnerabilities, installs with low friction, and fills a specific niche in spatial optimization that is not easily replicated by combining other packages. Install it if you are solving regionalization, facility location, or network-based optimization problems on geographic data; skip it if your work is purely aspatial or does not require constraint-based optimization.
Install
spopt on PyPI
Before you install
Low friction installation with a pure-Python wheel. Actively maintained as of July 2026 with a stable release cycle; 13 runtime dependencies are all mature, widely-used scientific libraries.
Requires Python 3.11 or later; pulp solver backend needs an external optimization engine (CBC is included by default).
License in practice
BSD 3-Clause is permissive; you may use, modify, and distribute spopt freely in commercial or proprietary projects provided you retain the license notice.
Quickstart
pip install spopt
import spopt
import geopandas
import libpysal
import numpy
mexico = geopandas.read_file(libpysal.examples.get_path("mexicojoin.shp"))
w = libpysal.weights.Queen.from_dataframe(mexico)
model = spopt.region.MaxPHeuristic(mexico, w, ["PCGDP1950"], "count", 4, 2)
model.solve()
mexico["regions"] = model.labels_
Verify before relying
- Performance characteristics and scalability limits for large geographic datasets are not quantified in the fact sheet.
- Whether the package supports alternative solvers beyond pulp's default CBC backend.
Package facts
| License | BSD 3-Clause permissive |
| Python support | Supports the current Python release >=3.11 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 13 packagesgeopandaslibpysalmapclassifynetworkxnumpypandaspointpatspulpscikit-learnscipyshapelyspaghettitqdm |
| Maintenance | Actively maintained 396 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 102,102 / month, #12,891 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Intended Audience :: Science/ResearchLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Topic :: Scientific/Engineering :: GIS |
Evidence: spopt-0.7.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “spatial optimization regionalization”
- spoptSpopt solves spatial optimization problems including regionalization,…
- pysalPySAL is a meta-package that bundles 29 spatial analysis libraries…
- rectangle-packerPacks a set of rectangles with fixed orientations into a minimal-area…
Give your agent the search over MCP, or paste the wish link into any chat.
More GIS packages
Shapely provides Python tools for creating, manipulating, and analyzing 2D geometric objects (points, lines, polygons) using the GEOS library, with both scalar and vectorized NumPy-based operations.
pyproj provides a Python interface to PROJ, enabling cartographic projections and coordinate system transformations for geospatial applications.
GeoPandas extends pandas DataFrames to handle geographic data, combining pandas operations with shapely geometry and spatial analysis capabilities that would otherwise require a spatial database.
Install it if you work with geographic data in Python and want to avoid setting up a spatial database or learning a separate GIS tool.
geopy is a Python client for geocoding and distance calculation that converts addresses to coordinates and vice versa using multiple web-based geocoding services, and computes geodesic and great-circle distances between geographic points.
Install it if you need geocoding or distance calculations in your application.
Pyogrio provides fast, bulk-oriented read and write access to vector spatial data formats (Shapefile, GeoPackage, GeoJSON, etc.) via GDAL/OGR bindings, typically for use with GeoPandas GeoDataFrames.
h3 provides Python bindings to Uber's H3 geospatial indexing library, converting geographic coordinates into hierarchical hexagonal grid cells and performing spatial operations on them.
See also spaghetti · pointpats · inequality · spint · spreg · dask-geopandas · pysal · regionmask · cvxopt