Exercise 00: Getting Started with QGIS and Python#

QGIS#

In the first part of this exercise you will load data in QGIS. For the subsequent steps make sure to have the plugins installed as highlighted on the last page.

Note

If you are looking for a more comprehensive introduction to QGIS take a look a the course material for our course “Introduction to GIS” or the QGIS User Guide.

1. Load data from a geopackage file#

Add the example.gpkg file as a new connection to QGIS and check which tables are defined in the geopackage file.

Show the steps in QGIS.

For the table ne_10m_admin_0_countries check which attributes are available.

Show the steps in QGIS.

Load data from the geopackage into QGIS. Make sure to use the Execute SQL command to ensure that you only load the countries within Asia.

Show the steps in QGIS.

2. Add background TMS layer#

Ensure that you have enabled contributed service definitions in the QuickMapServices QGIS plugin. Add Bing Satellite and Wikimedia Map as background TMS layer using the QuickMapServices Plugin.

Show the steps in QGIS.

3. OpenRouteService (ORS)#

Confirm that the plugin is working by calculating the fastest route for the driving-car profile by just clicking on the map and defining start and end points. Your points should not be too far away, probably it’s good to start with a route within a city. Make sure that you add your ORS api key to the ORS Tools QGIS plugin.

Show the steps in QGIS.

3. ohsome API#

  • Confirm that the ohsome Tools QGIS plugin is working by downloading elements and their geometry using the Data-Extraction endpoint of the ohsome API.

  • Define a Centroid and use the default filter to query for building=* or (type:way and highway=residential)

Show the steps in QGIS.

Python#

Start the Jupyter notebook#

In the exercises you will use jupyter notebooks to work with Python. Here are the steps to start a jupyter notebook.

  • Make Firefox or Chrome your default Web Browser.

When using the Anaconda Navigator on Windows:

  • Select you environment (e.g. “Applications on geo”)

  • Launch Jupyter Notebook

env

When using the Anaconda prompt:

  • Open the “Anaconda Prompt” and move to the main folder of this repository.

  • Activate your environment.

  • Start the Jupyter notebook server: jupyter notebook

Run some Python code#

I would recommend to download and go through the examples in the python basics Notebook (next page). This notebook will tell you a few basic python skills. You will also learn how to load and write geodata using the GeoPandas library. Make sure to download the notebook file and open it locally with Jupyter.

You might also want to go through the examples from jckantor. Just download the file and open it in Jupyter on your computer.

Closing the Jupyter notebook#

  • Close the browser tabs

  • In the “Anaconda Prompt” with your running jupyter notebook server, press CTRL + C to abort the process.