Skip to main content

spopt: Spatial Optimization

Regionalization, facility location, and transportation-oriented modeling

tag unittests codecov Documentation License Code style: black

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.

Regionalization

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");

Facility Location

Coming Soon.

Transportation & Routing

Coming Soon.

Examples

More examples can be found in the Tutorials section of the documentation.

All examples can be run interactively by launching this repository as a Binder.

Requirements

Installation

spopt is available on the Python Package Index. Therefore, you can either install directly with pip from the command line:

$ pip install -U spopt

or download the source distribution (.tar.gz) and decompress it to your selected destination. Open a command shell and navigate to the decompressed folder. Type:

$ pip install .

You may also install the latest stable spopt via conda-forge channel by running:

$ conda install --channel conda-forge spopt

Contribute

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.

Support

If you are having trouble, please create an issue, start a discussion, or talk to us in the gitter room.

Code of Conduct

As a PySAL-federated project, spopt follows the Code of Conduct under the PySAL governance model.

License

The project is licensed under the BSD 3-Clause license.

Funding

This project is/was partially funded through:

National Science Foundation Award #1831615: RIDIR: Scalable Geospatial Analytics for Social Science Research

Metadata

Release files for spopt 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spopt 0.0.3
File Size Uploaded
spopt-0.0.3.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spopt 0.0.3
File Interpreter ABI Platform
spopt-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 12.4 kB

Release files / spopt-0.0.3.tar.gz

Download URL spopt-0.0.3.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
16c7b957fb864d1405fa0c06a456ced040361614d943d665650e5485b5d560ab
BLAKE2b-256 checksum
How to use checksums
9c67b5806e83e5f55637bc3469f997c35a3f0e89aa5c3b29d532be5cc9256c07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

Release files / spopt-0.0.3-py3-none-any.whl

Download URL spopt-0.0.3-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
595ce141ba74c76a86e799d13d08c46a060f03a7797547ae8f096cfc2379850a
BLAKE2b-256 checksum
How to use checksums
e9c8b9863a4817247e3f3096c0cc4c639ac82eab361981e94178cea0318951b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page