- Description
- How To Use
- References
- Author Info
This project contains important calculation modules (coded in the backend) for the Urban Performance tool to work properly. The Urban Planning Tool Urban Performance assesses the city's present and future performance by modeling investment projects or policies in a range of indicators related to the Sustainable Development Goals (SDG), including aspects such as poverty reduction, water management, energy, infrastructure, public transportation, climate action, etc. Urban Performance models multiple scenarios and spatial solutions to test the effectiveness of their contributions to sustainable development. Scenarios can serve
- Django
- Celery
- PostgreSQL
This tool does not provide an user interface, so all comunication with the tool is done via REST interfaces.
The general operation of the tools is as follows:
- A scenario must be created
- The scenario must be delimited by a study area, this is done by attaching data to the footprints table
- The scenario must have some assumptions, this is done by attaching data to the assumptions table
- Then Minimum Mapping Units data have to be attached to the scenario, this is done by attaching data to the mmu table
- Depending on the indicators used in the scenario, additional data might be required to be attached to the Minimum Mapping Units, this is done by attaching data to the mmu_info table
- Depending on the indicators used in the scenario, additional data might be required to be attached to the transit table and transit_info tables
- Depending on the indicators used in the scenario, additional data might be required to be attached to the jobs table and jobs_info tables
- Depending on the indicators used in the scenario, additional data might be required to be attached to the amenities table and amenities_info tables
- Depending on the indicators used in the scenario, additional data might be required to be attached to the roads table and roads_info tables
- Depending on the indicators used in the scenario, additional data might be required to be attached to the risk table and risk_info tables
- Finally, once all the needed data have been attached to the scenario, the scenario can be evaluated.
All the previous steps can only be done by using the user interface provided by the UPT Server Extension.
Disclaimer: This tool has only been tested on Ubuntu Server 18.04
To proceed with the installation
- Install the database server with the following command
sudo apt install postgresql-10 postgresql-10-postgis-3
- Connect to to your database server with the following command
sudo su postgres && psql
- Create a database with the following command
create database upt_up;
; the database name can be adjusted as needed. - Create a user with the following command
create user upt with password '1234567890' SUPERUSER CREATEDB LOGIN;
; the username and pasword can be adjusted as needed. - Connect to the database with the following command
\c upt_up;
- Create the PostGIS extension in the database with the following command
create extension postgis
-
It's necessary to install the virtualenv package in the server that will host the applicaton. To do so, execute the following command
sudo apt-get install virtualenv
-
Create a Python 3 virtual environment by executing the following command
virtualenv -p python3 ~/python3
. This will create the directorypython3
in the user's home directory -
After the creation of the virtual environment has finished, the virtual environment must be enabled; this can be done by excecuting the following command
source ~/python3/bin/activate
-
Once the virtual environment has been enabled, the following python packages need to be installed. Use the command
pip install NAME_OF_THE_PACKAGE
- numpy
- psycopg2_binary
- architect
- sqlalchemy
- redis
- Celery
- python-decouple
- django
- djangorestframework
- django-filter
- django-filters
- django-celery-results
-
Once all packages have been installed, clone this project repository into the server. Move to the user's home and execute the following command
git clone https://github.com/UPTechMX/UPT-UrbanPerformance
, this will create a directory namedUPT-UrbanPerformance
in the user's home. -
Move to the newly created directory with the following command
cd ~/UPT-UrbanPerformance
-
Inside the
UP
directory, create a.env
file; use the.env.example
as a template -
Set the appropiate credentials to the newly created
.env
file -
Don't forget to set a secure
SECRET_KEY
in the same file
- Execute the command
python manage.py makemigrations plup
- Execute the command
python manage.py migrate plup
- Start the application with the command
python manage.py runserver 80
- Finally execute the command
celery -A UP worker --loglevel=error
to start the Celery worker
After following the previous steps, the application should be accesible through port 80. If the server has a firewall, set up the firewall to allow incomming connections to port 80.
Edit the dictionary PARALLEL
instantiated in the file ~/UPT-UrbanPerformance/UP/settings
to set the values that best fits the server resources, use the attribute MAX_THREADS
to set the maximun cores available in the server.
Since the tool does not use any login mechanism, to prevent undesired access to the tool use the variable ALLOWED_HOSTS
to only allow the UPT Server Extension to access the application. The variable is available in the file ~/UPT-UrbanPerformance/UP/settings
.
By default all logs are stored under the directory /tmp/
of the server, to change the logs location edit the file ~/UPT-UrbanPerformance/plup/logging_config.py
and set the appropiate value 'filename': '/tmp/debug-up.log'
.
It's possible to install the application and the database in different servers. To achieve this, it's necessary to appropriately set up the database connections.
For detailed infomation about Djagno please visit https://www.djangoproject.com/
For detailed infomation about Celery please visit http://www.celeryproject.org/
For detailed infomation about how to use Celery with Django please visit http://docs.celeryproject.org/en/latest/django/index.html
- SPDX-License-Identifier: MIT
- Copyright (c) 2020 CAPSUS S.C.
We acknowledge the invaluable support of the World Bank’s Trust Fund for Statistical Capacity Building (TFSCB) in making this project. This tool was conceptualized at City Planning Labs with the technical support from SITOWise. The tools were developed by CAPSUS and are maintained by UPTech and a community of developers.