Difference between revisions of "Training Material for 2019 UN Open GIS Challenge 2 - Open geospatial data and software for UN SDG 16, Peace justice and open institutions"

From OSGeo
Jump to navigation Jump to search
Line 69: Line 69:
  
 
Once Postgres is installed, we can connect to our Heroku database with the following steps, which are illustrated in Figure 5(a-b).
 
Once Postgres is installed, we can connect to our Heroku database with the following steps, which are illustrated in Figure 5(a-b).
• On pgAdmin right click on [Servers] --> [Create Server]
+
 
 +
• On pgAdmin right click on [Servers] _ [Create Server]
 
• General --> Give a name for your server (e.g. heroku).  
 
• General --> Give a name for your server (e.g. heroku).  
 
• Go to the Connection tab as shown in Figure 5b and refer to the Heroku database credentials as shown in Figure 3h. Copy and paste the information to the following inputs:  
 
• Go to the Connection tab as shown in Figure 5b and refer to the Heroku database credentials as shown in Figure 3h. Copy and paste the information to the following inputs:  

Revision as of 06:14, 9 February 2020

Introduction

United Nations (UN) have identified 17 interconnected goals to achieve a better and more sustainable future for all until the end of 2030. These Sustainable Development Goals (SDGs) range from ending poverty to ensuring gender equality. In order to address most of these goals, it is imperative to have a better understanding of geographic information science and technology, as any ‘event’ has a particular geographic location. The aim of this educational tutorial is to investigate the use of Free and Open Source Software (FOSS) to address SDG 16: ‘Peace, Justice and Open Institutions’.

Scope

The following educational material has been drafted within the framework of the 2019 OSGeo UN Committee Educational Challenge entitled ‘Open geospatial data and software for UN SDG 16, Peace justice and open institutions’. The seventh target of SDG 16 is to ‘ensure responsive, inclusive, participatory and representative decision-making at all levels’. Consequently, UN officers and patrols might need to collect geospatial data on the field to provide quantitative measures to address this target. In that respect, we have investigated the use of QField, which is an open source mobile data collection platform that could directly be connected to QGIS. The investigated tasks include real-time editing of geographic features, recording photos and developing a web-interface to display the collected data. There are several cloud based application development platforms and this tutorial relied on Heroku due to its support for PostgreSQL/PostGIS as well as different web programming languages. Any user could open a free account to test their ideas on Heroku.

Audience

We have prepared this educational material for researchers, educators and professionals in local, regional, national or international agencies with minimal geospatial information knowledge. We assume our audience has introductory knowledge of database management systems and programming. Nevertheless, the tutorial is intended to be self-contained meaning that anyone following the steps could understand and implement what had been achieved in this tutorial.

License

This educational material was prepared by Berk Anbaroğlu under the mentorship of Maria Brovelli, Serena Coetzee and Timur Obukhov. In addition, İhsan Buğra Coşkun and Mohammad Almasri contributed to the development of this tutorial. We would like to thank Agit Oktay for his support regarding the development of the web interface. Last, we would like to thank Matthias Kuhn who helped us with various issues regarding QGIS and QGField, and for his suggestion to use Syncthing. The material is distributed under Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license. This entitles that the users of this tutorial could share and adapt this content as long as the attribution is provided and that the same license is used upon adaptations. This tutorial has been kindly supported by the 2019 OSGeo UN Committee Educational Challenge.

Software Used

• PostgreSQL (Postgres) 11.5 is used to create the database that would store the collected data. PostGIS 2.5.3 extension is used to handle spatial data.

• QGIS 3.10 is used to create the project based on the data stored in the Postgres.

• QField 1.2.0 is used for mobile data collection and editing.

Syncthing is used to synchronize collected photos.

• NodeJS 12.13.1 is used to visualize the collected data on the web.

• Visual Studio Code 1.41.0 is the Integrated Development Environment for developing the JavaScript code.

• Git is a version control system that is required to deploy the web based application.

Scenario

United Nations (UN) officers require mobile field data collection for various purposes, mainly of which is to provide reliable measures to the indicators of targets. It is necessary to provide an easy-to-follow tutorial that will ease the process of mobile spatial data collection of UN officers. This tutorial addresses some of the practical requirements of mobile spatial data collection including offline data collection, attaching photos to recorded events, editing of spatial features on the field and displaying the collected data on the internet through a simple scenario.

The scenario in this tutorial is recording the location and thematic information of trees in a region. Specifically, a lecturer specifies polygons for which each student is responsible. Thereon, students go to the field to collect the information regarding trees in that region. Some of the regions might have limited broadband coverage, which requires students collect offline data, and some students may capture photos of trees. Finally, it would be interesting to visualise the collected data on the internet so that decision makers (lecturers) could have a better understanding of over/under mapped regions. The scenario can easily be adopted for an operational task that necessiates mobile spatial data collection.

The overview of this tutorial is illustrated in Figure 1:

Figure 1. Overview of the tutorial

The scenario utilised in this tutorial is recording the location and thematic information of trees in a region. Specifically, a lecturer identifies polygons in which each student is responsible for. Thereon, students go to the field to collect the information regarding trees in that region.

Acquired Knowledge

After going through the entire educational material, one will be able to understand the process to develop a mobile geospatial data collection platform using technologies including QField, QGIS, Postgres/PostGIS and Syncthing.

Setting Up the Environment

This section describes the required steps to set up the development environment. In order to realise the steps described in subsequent sections in a smooth manner, it is recommended that the users:

• Open a Heroku account

• Install PostgreSQL and PostGIS on their local computer

• Connect the Heroku database from QGIS

• Set up the project in QGIS

• Transfer the project from desktop PC (QGIS) to mobile data collection platform (QField).

Opening a Heroku Account

A database server should be available in the web to initiate a mobile geographic data collection project. There are several solutions that offer a free solution to this. One of the platforms supporting Postgres and PostGIS is Heroku, which is a platform as a service (PaaS) that enables developers to build, run, and operate applications entirely in the cloud. Therefore, this tutorial relied on Heroku to set up the database on the cloud.

The sign up page of Heroku, as illustrated in Figure 2, requires some personal information such as name, surname and email address.

Figure 2. Sign up page of Heroku

Once the form is submitted, an email is sent to verify the account. These credentials is used to create a new app. The second step is to create the database as illustrated in Figure 3(a-h). figg

The credentials of the database (Figure 3h) include the configuration details, such as the URL of the host and name of the database, user name, port and password. These details are private, so a grey rectangle is used to cover them.

Installing PostgreSQL / PostGIS

This step is optional. Specifically, a user interface that can connect to a Postgres database such as pgAdmin or DBeaver would be sufficient. Readers who may want to install Postgres on their local computers can follow this subsection.

This tutorial relied on Postgres 11.5 and PostGIS 2.5.3. Once Postgres is downloaded to the user’s local computer, it comes with an application called ‘Stack Builder’, which allows installing extensions to Postgres, including PostGIS. The extension has to be installed through Stack Builder as shown in Figure 4. figg

PgAdmin 4 provides an easy-to-use Graphical User Interface (GUI) to access and manipulate a Postgres database.

Once Postgres is installed, we can connect to our Heroku database with the following steps, which are illustrated in Figure 5(a-b).

• On pgAdmin right click on [Servers] _ [Create Server] • General --> Give a name for your server (e.g. heroku). • Go to the Connection tab as shown in Figure 5b and refer to the Heroku database credentials as shown in Figure 3h. Copy and paste the information to the following inputs: o Host name/address: Host o Maintenance database: Database o Username: User o Password: Password (check the ‘Save password’ box for ease of login in future) • Finally go the ‘Advanced’ tab and state the name of the database as it appears on Heroku (i.e. the same value used for the ‘Maintenance database’), so that only the relevant database would be visible.