Public Infrastructure Service Access (PISA)
PISA assists policymakers in identifying and planning key resources such as roads, bridges, and healthcare centres. It helps to optimise the placement of new infrastructure investments. Its goal is to increase access to public services, reduce expenses, and improve the quality of life in a region.
Documentation
For detailed documentation on the code, read the docs.
⚠️ Important:
The latest version of PISA contains significant refactoring and improvements.
If you need the original codebase, use version0.1.0available from the GitHub releases or refer to the list of releases for more information.
For new projects and ongoing development, it is recommended to use the latest version to benefit from updated features and optimizations.
User Installation
To install the latest version of PISA, you can use pip:
pip install pisa_abw
It is recommended to use a virtual environment to avoid dependency conflicts.
Local Development
Installation
The source code of this project can be installed in two ways to make it accessible for development and testing:
Option 1: Using Poetry (Recommended)
This project uses Poetry for dependency and packaging management.
Install Poetry by following the official installation instructions
Clone the repository:
git clone https://github.com/yourusername/Public-Infrastructure-Service-Access.gitNavigate to the repository folder:
cd Public-Infrastructure-Service-AccessInstall the project and its dependencies:
poetry install
Option 2: Using pip and venv
If you prefer traditional Python package management:
Clone the repository:
git clone https://github.com/yourusername/Public-Infrastructure-Service-Access.gitNavigate to the repository folder:
cd Public-Infrastructure-Service-AccessCreate a virtual environment:
python -m venv venvActivate the virtual environment:
Windows:
venv\Scripts\activatemacOS/Linux:
source venv/bin/activate
Install the package:
pip install dist/pisa_abw-XXXXX-py3-none-any.whlwhereXXXXXis the version number of the latest build.
If you need the original codebase, use the wheel file for version
0.1.0(pip install dist/gpbp-0.1.0-py3-none-any.whl)
External Dependencies
PISA requires additional tools for certain functionality:
Optimization Solver: Used to optimize the location of new facilities.
For beginners, we recommend the COIN-OR Branch-and-Cut solver (CBC)
Note the path to the executable of
cbcfor configurationAdvanced users can substitute CBC with other solvers compatible with the package
Mapbox API (Optional): Used to generate facility isopolygons.
Get your API key from the Mapbox account dashboard
After installing cbc and/or creating a Mapbox API key, create a .env file in the repository root with the following settings:
# Path to your cbc solver executable (for optimization)
CBC_SOLVER_PATH=<path_to_solver>
# Mapbox API key (optional, for isopolygon generation)
MAPBOX_API_TOKEN=<your_api_key_here>
This file is ignored by git by default for security.
Usage
We provide two examples to understand and interact with the package:
Some example usage can be seen in the
examples/pisa_showcase_*.ipynbnotebooks. These notebooks show the basic package data flow and allow you to explore the outputs of each function. The notebooks differ in the tool used to generate isopolygons: OSM or Mapbox. Note that Mapbox requires an API key (see External Dependencies section above).A more visual example can be seen in the Streamlit app to interact with the package using a graphical interface. You can start the app by running
streamlit run pisa_app/main_page.pyfrom the main repository directory, which will automatically open a browser window.
Deploying/running the web interface (Docker)
Docker is a tool that allows you to package an application and its dependencies in a virtual container that can run on most operating systems. The web interface for the PISA project can be run using Docker. To do this, you need to have Docker installed on your system. You can download Docker from here.
After you have installed Docker, you can run the following command in the repository to build an image of the PISA project. The Dockerfile uses Poetry to install the application and its dependencies inside the image, consistent with the recommended installation method, and includes all necessary geospatial libraries.
docker build -t pisa .
Now that you have built the image, you can run a container using it. The following command will run a container from the pisa image and expose the web interface on port 8501 to localhost only. The command will show the URL on which it’s accessible. The container will be named pisa as well.
docker run -p 127.0.0.1:8501:8501 --name pisa pisa
You can use the following commands to manage the container after the initial run:
# Stop the container
docker stop pisa
# Start a stopped container
docker start pisa
# View logs from the container
docker logs pisa
# Remove the container (if you need to start fresh)
docker rm pisa
The image is also ready to be deployed on a server or a cloud platform that supports Docker.