Spopt is an open-source Python library for solving optimization problem with spatial data. Originating from the region
module in PySAL (Python Spatial Analysis Library), it is under active development for the inclusion of newly proposed models and methods for regionalization, facility location, and transportation-oriented solutions.
import spopt, libpysal, geopandas, numpy
mexico = geopandas.read_file(libpysal.examples.get_path("mexicojoin.shp"))
mexico["count"] = 1
attrs = [f"PCGDP{year}" for year in range(1950, 2010, 10)]
w = libpysal.weights.Queen.from_dataframe(mexico)
mexico["count"], threshold_name, threshold, top_n = 1, "count", 4, 2
numpy.random.seed(123456)
model = spopt.MaxPHeuristic(mexico, w, attrs, threshold_name, threshold, top_n)
model.solve()
mexico["maxp_new"] = model.labels_
mexico.plot(column="maxp_new", categorical=True, figsize=(12,8), ec="w");
Coming Soon.
Coming Soon.
PySAL-spopt is under active development and contributors are welcome.
If you have any suggestions, feature requests, or bug reports, please open new issues on GitHub. To submit patches, please review PySAL: Getting Started, the PySAL development guidelines, the spopt
contributing guidelines before opening a pull request. Once your changes get merged, you’ll automatically be added to the Contributors List.
As a PySAL-federated project, spopt
follows the Code of Conduct under the PySAL governance model.
The project is licensed under the BSD 3-Clause license.
This project is/was partially funded through: