This project shows how to integrate your own georeferenced simulation region into a MARS model. The georeferenced data include graphs from OpenStreetMap (OSM) and Point of Interest (POI) data from Geofabrik/OSM. The functionality for obtaining georeferenced data is encapsulated in a provided Docker container.
There are several ways to run and use the Docker container, four of which are outlined below.
To set up the container on your own machine, please follow these steps:
- Install Docker Desktop and start it.
- Run the bash script
./notebookdocker.sh
on Linux/macOS or the./notebookdocker.bat
on Windows in your terminal. Do not close the terminal after the script has finished running (doing so would shut down the container). - Open JupyterLab on http://localhost:8888/.
Alternatively, if you have no access to Docker (e.g., when working on a HAW lab computer), you can use the JupyterHub of the HAW ICC. Note that a HAW account is needed for this.
- Login into the JupyterHub.
- Select an instance (no GPUs are needed).
- Upload the three
*.ipynb
files and open and execute them (see steps below).
The documentation of the HAW JupyterHub can be found here.
Another alternative is to use Google Colab. Visit Google Colab, start a session, and upload the three *.ipynb
files and open and execute them (see steps below).
Note that you usually have no persistent storage on Google Colab. Any downloaded data need to be saved locally before the Google Colab session is terminated.
With the provided Docker container, you have a ready-to-use JupyterLab instance with all installed dependencies. However, you are free to use your own Jupyter Notebook instance instead of using the provided Docker container. In this case, you will need to install the required dependencies yourself.
Note
Some of the Geographic Information System (GIS) dependencies of the used Python libraries are known to be difficult to install. Please see this and this StackOverflow post for more information. If you work on a Windows machine and are unable to install dependencies withpip
, please see this Wheel (WHL) file depository.
Once you have set up the Docker container (or set up your own Jupyter Notebook instanced properly), you can start to work with this blueprint. The blueprint provides two key functionalities:
- Downloading georeferenced vector data
- Integrating these data into a MARS model blueprint
Georeferenced data can be downloaded with the provided Jupyter notebooks, and agent-based simulations (that use the downloaded georeferenced data) can be run with the provided MARS model blueprint. The notebooks provide a starting point for downloading data and further filtering/adjusting them to your needs. Specifically, the notebooks provide the following functionality:
Download Graph.ipynb
: downloads georeferenced graph data (e.g., travel networks)Prepare POIs.ipynb
: downloads georeferenced point-of-interest data (e.g., buildings, parking areas, etc.)Analyze.ipynb
: provides analysis of simulation results
A typical workflow for using this blueprint might consist of the following steps:
- Define an area of interest (AOI)
- Obtain travel layers for your AOI using
Download Graph.ipynb
- Obtain POI data for your AOI using
Prepare POIs.ipynb
- Run simulations of the provided MARS model (with the data obtained in steps 2 and 3)
- Analyze simulation results using
Analyze.ipynb
Defining an AOI (step 1) is up to you and usually depends on your research question and/or modelling needs. Steps 2—5 are outlined in the following four sections, respectively.
The AOI in which the simulation will be situated needs to be defined and described in a Well-Known Text (WKT) geometry file. Such a file can be generated with, for example, https://geojson.io/. Follow these steps to draw and save a rectangle that represents your AOI:
- From the toolbar at the top right of the map editor, select the button with the square
- Double-click on the map where you want to start drawing the rectangle
- Drag your mouse to shape the rectangle
- Click to fix the rectangle
- Save the rectangle as a WKT file (
Save > WKT
in the menu above the map).
For movement of our agents, we need a street network (graph). To get such a graph, we use data from OSM.
After you saved the file, open the provided Jupyter Notebook Download Graph.ipynb
in JupyterHub for further information. Make sure you see the downloaded WKT file alongside the notebook JupyterHub, if not upload it.
For POI data, we utilize OSM data as well. The people of Geofabrik have done some preprocessing of raw OSM data, which makes the ingestion into the model easier. See the .shp file download for South Africa here: south-africa-latest-free.shp.zip (all other countries are provided as well). For our AOI of Port Elizabeth, we now need to extract all relevant POIs like restaurants, cafes, shops, etc.
For this, please download the data and have a look at the Prepare POIs.ipynb
notebook, as before you might need to upload and rename the WKT file as well.
In this starter template, the data needed for running a simulation on the area of Port Elizabeth have already been downloaded and put into the Resources folder of the model at GeodataBlueprint/Resources
.
If you did run the both notebooks with a new AOI and the provided Docker container, the files have already been updated (to prevent data loos existing files for the graph and POIs are renamed to bkp_*
files in the Resources directory if you need them later).
In case you did run the notebooks on an other JupyterHub download the created GeodataBlueprint/Resources
folder and copy it's contents into the local folder.
To run the model open the GeodataBlueprint.sln
with Rider and run it.
After running the model, some log files and movement files are available that we now can analyze.
For analysis of the created data, please have a look at the Analyze.ipynb
notebook. It shows some basic statistics about the model as well as an interactive map with the movement of your agents.