FOSS4GUK Workshop: Collecting data with QGIS, Input and Mergin

SEPTEMBER 19, 2019 input mergin qgis

During FOSS4GUK 2019 in Edinburgh we ran a workshop for collecting data using Input. This is the content of the workshop with all the datasets.

Prerequisites

To be able to work with Input, you will need the following:

Setting up the survey project

For the purpose of this workshop, we have prepared a QGIS project. Let’s use that as a starting point:

  • Log into Mergin
  • In the top-left, click on Projects and select Explore
  • Find and click on saber/foss4guk
  • In the top panel, click on the mergin_clone icon to create a copy of the project under your own Mergin account (foss4guk_YOURNAME)

Exploring the project in QGIS

The project you have copied in Mergin, is a QGIS project with various map layers. To see the content of the project in QGIS:

  • In Mergin, in the top menu, select Projects > My projects

  • Select foss4guk_YOURUSERNAME (or the name you assigned when copying the project).

  • In the top menu, click on the mergin_download icon to download the project

  • Extract the content of the zip file

Alternatively:

The above process can be done through the Mergin plugin for QGIS. To do that:

  • Install the Mergin plugin in QGIS

  • Restart QGIS

  • In the QGIS Browser panel, right-click on Mergin and select Configure

  • Enter your Mergin username and password

  • Under My Project, right-click on foss4guk_YOURUSERNAME and select Download

  • Select a location under which the project will be downloaded to

  • Once downloaded, select Open to open the project.

Layer settings and forms

Input is based on QGIS, therefore, any layer symbology / styles you set in QGIS, will be displayed in Input. If you are using SVGs (e.g. OS MasterMap), you need to embed these in the QGIS project.

Input also supports most of the edit widgets from QGIS. Edit widgets allow you to simplify filling-in forms with drop-down options, TRUE/FALSE switches, sliders, calendar and time, default values, attachments, value relations and more. To see some of those settings:

  • From the Layers panel (in QGIS), right-click on the listed buildings (points layer) and open the Properties window.

  • From the left-hand panel, select Attributes Form. Explore the various widgets assigned to different fields.

For this layer, we have set the Photo field to use an Attachment widget. This will allow Input to make use of your mobile camera to attach photos to features.

For the Surveyor field, we have linked it to an external CSV table, to populate a drop-down option with the names of surveyors.

Input can also use a pop-up window (similar to Google Maps) to display basic information about a single feature:

To customise this pop window’s content:

  • Open the properties table, and select the Display tab

  • You can see the title is set to ENT_TITLE and there is an image tag referencing the Photo field:

      # image
      file:///[%@project_folder%]/[% "Photo" %]
    

Map themes

To simplify handling layer visibility, Input makes use of map themes defined in your QGIS project. In this project, there is a map theme for aerial photo (using a Bing aerial layer) and OpenStreetMap (geopackage).

[]{#anchor-5}Survey layer

In Input, any vector layer (point, line, polygon) can be edited (as long as editing that format is supported in QGIS). This could be very confusing when dealing with large numbers of vector layers in a single project (trying to figure out which one to edit).

Luckily you can set background layers (or those you don’t want to be editable in Input) to read-only:

  • In QGIS, from the main menu, select Project > Properties

  • In the new window, select the Data Sources tab from the left-hand panel

Below is the list of layers and their capability settings for the project. Layers not marked as read-only will be shown as survey layers (editable) in Input.

By default, the file paths to layers are relative. You can change that under the General tab of this window.

Using Input

To use Input, open the app on your device. On its first run, Input will show the Projects page.

  • Under Projects, select My projects
  • From the list, find YOUR_Mergin_USERNAME/foss4guk_YOURUSERNAME (e.g. saber/foss4guk_saber)
  • Tap the download icon on the right-hand side of the project to download the project (warning: if you are not connected to WiFi, this will use some of your mobile data allowance)
  • After downloading, tap Home
  • Select your downloaded project

When you open the project, you may not see all layers. This is because some of the layers have zoom-dependant visibility settings (again configured in QGIS).

Exploring the project

To switch map themes:

  • Tap More on the bottom-right side of the screen

  • Tap Map themes > aerial photo

You can also display feature details simply by tapping on them.

  • Tap on the point representing Queensberry House:

Capturing data

To capture data:

  • Tap Record

  • You can then choose the layer in which you want to record your feature, by tapping on the light green band, in the lower part of the screen, above the Input menu.

  • If you are capturing a point, by default, the suggested point to capture will be on your GPS location. You can drag the map to adjust the location of the new point. To switch back to the current GPS location, tap the GPS icon on the bottom-left of your screen.

  • After adding a point, you will be prompted to fill-in the form.

If you are recording a line or a polygon, you can either add points to define the shape of your feature or press and hold the GPS icon when in Record mode to generate a shape from your GPS track.

Editing data

You can edit the existing features on your map. For point layers, you can edit geometry and form data. For lines and polygons, you can edit only the form data.

Try it!

Let’s get out and capture some data for the Path layer!

Uploading your changes

Once you have made changes to your data, you can upload them back to Mergin:

  • In Input, tap Projects

  • Select My projects

  • Click on the sync/refresh icon to the right of your project

You can now download the project again to your desktop and see the changes in QGIS. Alternatively, you can synchronise the changes you made back to QGIS by using the Mergin plugin for QGIS (described earlier).


Posted by Saber Razmjooei