Team:Terrain/QGIS Intro

From WHY2025 wiki
Revision as of 00:05, 16 January 2025 by Gina (talk | contribs) (Created page with "This year, Team:Terrain is using a PostGIS database to manage the map data. The easiest way to interact with this database for the teams is to use [https://qgis.org/ QGIS]. If you are only looking for a pre-rendered view of the map check out our PDF maps, those should be good enough for most read-only access. In order to access the database you will need credentials that are given out per team, if you need access please contact Team:Terrain. Team:Terrain will supply yo...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This year, Team:Terrain is using a PostGIS database to manage the map data. The easiest way to interact with this database for the teams is to use QGIS.

If you are only looking for a pre-rendered view of the map check out our PDF maps, those should be good enough for most read-only access.

In order to access the database you will need credentials that are given out per team, if you need access please contact Team:Terrain. Team:Terrain will supply you with a QGIS file, a username and a password. You will also need a VPN connection, please make sure you activate that before following the rest of this documentation.

A short intro to the database layout

We use PostgreSQL as our database management system (DBMS) with the PostGIS extension to support spatial data.

In the DBMS we use a database called

qgis

(this is just a name chosen by us) and within that database we have several schemata.

Each schema can contain several tables, and each table corresponds to a layer of the map.

A noteworthy schema is the

why25

schema, which Team:Terrain uses to put layers that are relevant for everyone, everyone should have read access to this database.

Each team (that has access to the database) gets their own schema to put tables in, in which they then have write access. These are just named after the corresponding teams, note that all database-users have read-access to these schemas as well.

QGIS File vs Database

Screenshot 20250115 221009 cropped.png

A QGIS project is mainly a collection of layers. These layers are just a name and some information on where to fetch the data from; meaning that the QGIS file only contains information on where to find the layer, but not the actual spatial data. This where-information from can take several forms, but all the layers in the project file you get from Team:Terrain are loaded from the database. Looking at the image, you can see two windows. The Browser window, which has a list of data sources, think of this as potential layers that your project not yet has; and the Layers window, which lists the layers for the current project, so the ones that are actually loaded.

While it is possible to save the entire layer in the QGIS project, we advice against that for backup and collaboration reasons.

Connect to Database and Adding Layers

If you want to add a layer from the database to your project you need to establish a database connection. To do so, right-click on PostgreSQL in the Browser window and select add connection. The configuration should then look something like the image below (replace the username and password with your teams):

Screenshot 20250115 221137.png

Click the Test Connection button to make sure that it works. Once you click OK, you should now have a database connection.

In the Browser window and you can drag and drop tables from there into the Layers window to add them to your project. Please note that your database credentials are then saved in the QGIS Project as part of the layers "where does my data come from"-information.

If you want to create a new layer, the easiest is to right-click your schema in the Browser window and clicking "Add Table". You then need to give the table a name and select a geometry type. This table is then an empty layer when added to the QGIS project and you can add your features onto it.

If you would like an intro to how to edit with QGIS for WHY purposes, let Team:Terrain know we are happy to explain more, but you can always create yourself a test project without the database or a test-layer in your schema to play around with. Happy Hacking!