spopt
spopt: a python package for solving spatial optimization problems in PySAL - Published in JOSS (2022)
Science Score: 95.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 8 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org, zenodo.org -
✓Committers with academic emails
2 of 21 committers (9.5%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
Keywords from Contributors
Scientific Fields
Repository
Spatial Optimization
Basic Info
- Host: GitHub
- Owner: pysal
- License: bsd-3-clause
- Language: Python
- Default Branch: main
- Homepage: https://pysal.org/spopt/
- Size: 160 MB
Statistics
- Stars: 339
- Watchers: 12
- Forks: 55
- Open Issues: 30
- Releases: 19
Topics
Metadata Files
README.md
spopt: Spatial Optimization
Regionalization, facility location, and transportation-oriented modeling
Spopt is an open-source Python library for solving optimization problems 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
python
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.region.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");
Locate
```python from spopt.locate import MCLP from spopt.locate.util import simulatedgeopoints import numpy, geopandas, pulp, spaghetti
solver = pulp.PULPCBCCMD(msg=False, warmStart=True) lattice = spaghetti.regularlattice((0, 0, 10, 10), 9, exterior=True) ntw = spaghetti.Network(indata=lattice) street = spaghetti.elementasgdf(ntw, arcs=True) streetbuffered = geopandas.GeoDataFrame( geopandas.GeoSeries(street["geometry"].buffer(0.5).unaryunion), crs=street.crs, columns=["geometry"], ) clientpoints = simulatedgeopoints(streetbuffered, needed=100, seed=5) ntw.snapobservations(clientpoints, "clients", attribute=True) clientssnapped = spaghetti.elementasgdf( ntw, ppname="clients", snapped=True ) facilitypoints = simulatedgeopoints(streetbuffered, needed=10, seed=6) ntw.snapobservations(facilitypoints, "facilities", attribute=True) facilitiessnapped = spaghetti.elementasgdf( ntw, ppname="facilities", snapped=True ) costmatrix = ntw.allneighbordistances( sourcepattern=ntw.pointpatterns["clients"], destpattern=ntw.pointpatterns["facilities"], ) numpy.random.seed(0) ai = numpy.random.randint(1, 12, 100) mclpfromcostmatrix = MCLP.fromcostmatrix(costmatrix, ai, 4, pfacilities=4) mclpfromcostmatrix = mclpfromcostmatrix.solve(solver) ``` see notebook for plotting code
Examples
More examples can be found in the Tutorials section of the documentation. - Max-p-regions problem - Skater - Region K means - Facility Location Real World Problem
All examples can be run interactively by launching this repository as a .
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
Related packages
- Region
- Locate
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's documentation for developers, 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 PySAL's Discord channel.
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.
Citation
If you use PySAL-spopt in a scientific publication, we would appreciate using the following citations:
``` @misc{spopt2021, author = {Feng, Xin, and Gaboardi, James D. and Knaap, Elijah and Rey, Sergio J. and Wei, Ran}, month = {jan}, year = {2021}, title = {pysal/spopt}, url = {https://github.com/pysal/spopt}, doi = {10.5281/zenodo.4444156}, keywords = {python,regionalization,spatial-optimization,location-modeling} }
@article{spopt2022, author = {Feng, Xin and Barcelos, Germano and Gaboardi, James D. and Knaap, Elijah and Wei, Ran and Wolf, Levi J. and Zhao, Qunshan and Rey, Sergio J.}, year = {2022}, title = {spopt: a python package for solving spatial optimization problems in PySAL}, journal = {Journal of Open Source Software}, publisher = {The Open Journal}, volume = {7}, number = {74}, pages = {3330}, url = {https://doi.org/10.21105/joss.03330}, doi = {10.21105/joss.03330}, } ```
Funding
This project is/was partially funded through:
National Science Foundation Award #1831615: RIDIR: Scalable Geospatial Analytics for Social Science Research
Owner
- Name: Python Spatial Analysis Library
- Login: pysal
- Kind: organization
- Repositories: 37
- Profile: https://github.com/pysal
JOSS Publication
spopt: a python package for solving spatial optimization problems in PySAL
Authors
Center for Geospatial Sciences, University of California Riverside, Department of Geography and Environmental Sustainability, University of Oklahoma
Oak Ridge National Laboratory, The Peter R. Gould Center for Geography Education and Outreach, Penn State
Center for Geospatial Sciences, University of California Riverside
Tags
spatial optimization PySALPapers & Mentions
Total mentions: 1
Using the max-p regions problem algorithm to define regions for energy system modelling
- DOI: 10.1016/j.mex.2021.101211
- OpenAlex ID: https://openalex.org/W3120494411
- Published: January 2021
GitHub Events
Total
- Create event: 3
- Release event: 1
- Issues event: 23
- Watch event: 39
- Delete event: 2
- Issue comment event: 52
- Push event: 14
- Pull request review comment event: 27
- Pull request review event: 22
- Pull request event: 28
- Fork event: 6
Last Year
- Create event: 3
- Release event: 1
- Issues event: 23
- Watch event: 39
- Delete event: 2
- Issue comment event: 52
- Push event: 14
- Pull request review comment event: 27
- Pull request review event: 22
- Pull request event: 28
- Fork event: 6
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| James Gaboardi | j****i@g****m | 357 |
| Erin Olson | r****o@g****m | 206 |
| Germano Barcelos | g****s@g****m | 70 |
| Serge Rey | s****y@g****m | 65 |
| Xin Feng | x****g@X****l | 43 |
| pre-commit-ci[bot] | 6****] | 24 |
| eli knaap | ek@k****m | 23 |
| Xin (Selena) Feng | a****g@g****m | 15 |
| rongboxu | r****1@u****k | 14 |
| ljwolf | l****f@g****m | 10 |
| dependabot[bot] | 4****] | 7 |
| rwei5 | r****i@a****u | 6 |
| Timothy Ellersiek | t****m@g****m | 6 |
| Martin Fleischmann | m****n@m****t | 2 |
| github-actions[bot] | 4****] | 2 |
| Abhishek Dimri | 1****i | 1 |
| Emmanuel Ferdman | e****n@g****m | 1 |
| Krasen Samardzhiev | k****m@g****m | 1 |
| Nick Bearman | n****k@g****k | 1 |
| Patrick Roddy | p****y@g****m | 1 |
| Pedro Camargo | c@m****o | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 117
- Total pull requests: 128
- Average time to close issues: about 2 months
- Average time to close pull requests: 10 days
- Total issue authors: 23
- Total pull request authors: 17
- Average comments per issue: 1.88
- Average comments per pull request: 1.71
- Merged pull requests: 110
- Bot issues: 0
- Bot pull requests: 28
Past Year
- Issues: 19
- Pull requests: 33
- Average time to close issues: 15 days
- Average time to close pull requests: 9 days
- Issue authors: 7
- Pull request authors: 10
- Average comments per issue: 1.47
- Average comments per pull request: 1.76
- Merged pull requests: 22
- Bot issues: 0
- Bot pull requests: 4
Top Authors
Issue Authors
- jGaboardi (87)
- ljwolf (5)
- iboates (2)
- orlandombaa (1)
- xf37 (1)
- sjsrey (1)
- mbforr (1)
- nilason (1)
- swongraphy (1)
- samueltoro7 (1)
- Abhishek-Dimri (1)
- benjaminrhoyle (1)
- martinfleis (1)
- Anran0716 (1)
- Dekermanjian (1)
Pull Request Authors
- jGaboardi (66)
- pre-commit-ci[bot] (23)
- ljwolf (4)
- rongboxu (4)
- nightcoder26 (4)
- gegen07 (3)
- speco29 (3)
- xf37 (3)
- dependabot[bot] (3)
- emmanuel-ferdman (2)
- fengzixin0617 (2)
- Abhishek-Dimri (2)
- martinfleis (2)
- github-actions[bot] (2)
- u3ks (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 3
-
Total downloads:
- pypi 27,990 last-month
- Total docker downloads: 189
-
Total dependent packages: 5
(may contain duplicates) -
Total dependent repositories: 43
(may contain duplicates) - Total versions: 30
- Total maintainers: 3
pypi.org: spopt
Spatial Optimization in PySAL
- Homepage: https://pysal.org/spopt/
- Documentation: https://spopt.readthedocs.io/
- License: BSD 3-Clause
-
Latest release: 0.7.0
published 6 months ago
Rankings
conda-forge.org: spopt
Spopt is an open-source Python library for solving optimization problems with spatial data. Originating from the `region` module in [PySAL](http://pysal.org) (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.
- Homepage: http://pysal.org/
- License: BSD-3-Clause
-
Latest release: 0.4.1
published over 3 years ago
Rankings
anaconda.org: spopt
Spopt is an open-source Python library for solving optimization problems with spatial data. Originating from the `region` module in [PySAL](http://pysal.org) (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.
- Homepage: https://pysal.org/spopt
- License: BSD-3-Clause
-
Latest release: 0.7.0
published 4 months ago
Rankings
Dependencies
- actions/checkout v3 composite
- ad-m/github-push-action master composite
- mamba-org/provision-with-micromamba main composite
- actions/checkout v3 composite
- actions/github-script v6 composite
- actions/setup-python v4 composite
- pypa/gh-action-pypi-publish release/v1 composite
- actions/checkout v3 composite
- codecov/codecov-action v3 composite
- mamba-org/provision-with-micromamba main composite
- geopandas >=0.10
- libpysal *
- mapclassify *
- networkx >=2.6
- numpy >=1.21
- pandas >=1.3,!=1.5.0
- pointpats >=2.3.0
- pulp *
- scikit-learn >=1.0
- scipy >=1.7
- shapely >=2
- spaghetti *
- tqdm >=4.27.0
- folium
- geopandas
- glpk
- inequality
- jupyterlab
- libpysal
- mapclassify
- matplotlib
- matplotlib-scalebar
- networkx
- numpy
- overpy
- pandas
- pip
- pointpats
- pulp
- python 3.12.*
- scikit-learn
- scipy
- seaborn
- shapely
- spaghetti
- tqdm
- watermark