How to create AI train data with QGIS

From Tygron Preview Support Wiki
Jump to navigation Jump to search

In this how-to, we will use Areas to store our data in. Areas can overlap and be grouped together using a particular attribute, in this case FOLIAGE. The FOLIAGE attribute should contain a single integer number, which represents the classification. For example, we can use the following classification:

  1. Deciduous Tree
  2. Pine Tree
  3. Heath area
  4. Hedge
  5. Bush
  6. Reed
  7. Flower bed
  8. Leafless Tree Area

The areas are drawn on top of a particular Overlay or WMS Layer of your project. In this case we will use the original satellite background layer of a Project's WMS service.


Setup a Project with an attribute Area and copy the WFS link

How to Setup a Project with an attribute Area and copy the WFS link:
  1. Open your project in editor mode.
  2. Hover over Areas in the ribbon bar, and select Add new Empty Area.
  3. With the Area selected, select the Attribute tab in the Area Detail Panel.
  4. Under Add new Attribute, type FOLIAGE for name and 1 for value.
  5. Click Save New Attribute to add the FOLIAGE attribute.
  6. Click on the Group by Attribute button in the Area Overview Panel.
  7. Add the same Attribute name as added for the Area in the previous steps.
  8. Next, hover over Areas in the ribbon bar and select Export Geo Data
  9. For Filter, select Foliage
  10. Select any of the GeoJSON options.
  11. Click on the Copy the URL button next to Web Feature Service (WFS)

Setup QGIS with a Project's Area WFS and a Satellite Background

How to Setup QGIS with a Project's Area WFS and a Satellite Background:
  1. Open QGIS
  2. In QGIS, Hover over Layer in the ribbon bar, and under add new Layer, select add WFS / OGC API Feature Layer
  3. In the Data Source Manager panel, select New.
  4. Paste the copied WFS url from the Export Geo Data panel and paste it in the url field.
  5. Provide an appropriate name, for example Foliage - My Project Name and confirm.
  6. Click on the Connect button.
  7. Select the layer named Foliage Areas and click on Add.
  8. In the Tygron Application again, hover over Overlays and select Export Grid Data
  9. Click on the Copy URL
  10. In QGIS, hover over Layer again, and under add new Layer, select add WMS/WMTS.
  11. Click on add new.
  12. For the URL field, paste the copied Web Map Service (WMS) URL.
  13. For the name, write Satellite - My Project Name and click on OK to confirm.
  14. Click on connect and select the layer named SATELLITE ORIGINAL and click add.
  15. In the Layers panel in QGIS, drag and drop the Foliage Layer above the Satellite Layer.

Setup the QGIS WFS Layer with a classification and attribute form

How to Setup the QGIS WFS Layer with a classification and attribute form:
  1. Right click on the Foliage Areas Layer, and select Properties
  2. In the Layer's Properties Panel, select the Symbology Tab.
  3. Changed the type to Categorized.
  4. Click on the plus button to add 1 category per class and add a final extra one.
  5. Per type, do the following:
    1. Add an entry and provide it with an floating point number, such as 1.0.
    2. Select a color
    3. Provide the name of the entry with the classification, for example Deciduous.
  6. Finally, add a final entry with no value and a color that significantly different from the classification colors, such as pink or purple. Name this entry Other.
  7. Click on the apply button.
  8. Next select the tab Attributes Form
  9. Change the option to Drag and Drop Editor.
  10. Under form Layout, remove all fields except the FOLIAGE field.
  11. Select the FOLIAGE field, and under general, select the Reuse last entered value option.
  12. Change the Text Field widget to Classification.
  13. Select apply to confirm.

Edit the WFS layer and add and edit features and saving the changes

How to Edit the WFS layer and add and edit features and saving the changes:
  1. Select the WFS layer in the layer panel.
  2. Select the Pencil option named Toggle Editing
  3. To add new Features, select the Polygon Star button
  4. Left click on the 2D View to add a vertices
  5. Right click to confirm the shape. The feature form appears.
  6. Provide the correct value and click on the OK button. You can also confirm by pressing the ENTER key, and cancel with ESC.
  7. To edit a feature's vertices, select the Vertex Tool button
  8. To edit a feature's form, first activate a Feature Select Option (yellow icons in the top bar), select one or more features and click on the pencil with attribute rows icon to edit the form.
  9. To delete a feature, use the Vertex Tool and select all vertices from a Feature. When an Area's polygon has no more vertices, it will be removed from the Tygron Project once the edits are saved.
  10. To save all changes made to the WFS Layer, click on the save button. This sends all changes to the session on the Tygron Platform.
  11. Optional: Toggle the magnet option when vertices should touch and tweak the pixel distance accordingly.

Notes

  • You can only access and edit a WFS service of a session that is active on the Tygron Platform.
  • You can choose to change the Attribute Form of the WFS Feature Layer to use the Classification instead of a text field with a number, in case the classification numbers are hard to remember.
  • We highly advice to save the configured style of a WFS Layer to a QML file. This save option is accessible in the Layer Properties panel in QGIS. The QML file includes the classification legend, as well as the attribute form. A QML File can also be loaded for other WFS services.

See also