7.4.5. Attribute table data editing

QGIS provides a set of editing tools and conventions similar to ArcGIS (see section 6.4.3.). To edit a vector layer, it has to be set into “edit mode” by the Toggle Editing function. As usual, this function is accessible by several buttons and menu entries:

  • Main menu Layer > Toggle Editing.
  • The button Toggle Editing text icon24 within the Digitizing toolbar or the Attribute table.
  • The context menu within the Map Legend > Toggle Editing.

If the Toggle Editing function is greyed out, the selected layer is probably not in an editable vector file format (not all the file formats that can be imported and displayed with QGIS may also be changed, so that in some cases a file conversion is necessary first) or accessed by another program or other users.

  1. Set the newly created layer containing all municipalities where colonies of honey bees were sighted into the Edit mode.
  2. In the Map Legend a pencil will appear to the left of the layers name and in the Map View the different vertices of the polygons are marked by transparent circles.
  3. Open the Attribute table and look at the buttons to the left (see Table 6):
  4. Now add a new field (column in the Attribute table) with the button text icon25, where additional values (e.g. the number of honey bee colonies) can be filled in.
  5. Within the Add column dialog, choose appropriate settings for name (avoiding special characters and blanks, e.g. ‘bees_colonies’), data type (e.g. integer, only whole numbers will be needed) and width (2 digits are sufficient as there will not be more than 99 colonies per entry).
  6. Now, fill in some numbers into the newly created fields as a test (Fig. 87).
    Because of the restriction to integer values of 2 digits maximum width, all types of characters and also numbers higher than 99 will be refused. This is one of the ways GISystems deal with aspects of data integrity.
  7. Click the Save Edits button text icon26 to make the changes permanent, i.e. written to the file system.

Save often to avoid data loss and finish successful edit sessions by turning the edit mode off (Toggle Edits button again > save all changes).

The number of honey bee colonies could be counted and written to the table manually, but of course QGIS provides several tools for this task that run automatically, even when the editing mode is not active or no empty field has been created before:

  1. Go to Vector.
  2. Choose Analysis Tools.
  3. Select Points in Polygon.
  4. Choose the appropriate input layers and a name for the new attribute field (e.g. “bee_colony”)
  5. Specify a path and a name for the new shapefile that will be created (Fig. 88).
  6. Click OK.
  7. Click Yes when asked if the newly created shapefile should be added to the table of contents (TOC).

In which commune are most honey bee colonies located?

  1. Switch back to the Attribute table of the new shapefile.
  2. Sort the attributes by descending in the field “bee_colony” (click the arrow beside of the column name).


Within the commune of “Düdingen”, with the “BFSNR” = 2293, 5 colonies of honey bees were found.

Table 6. The most important functions and the corresponding buttons for editing tasks.

Function

Icon

Purpose

Toggle editing mode

icon10

Start and End editing sessions. Changes have to be confirmed (or rejected) at the end of an editing session.

Save Edits

icon11

Saves the edits permanently.

Delete Selected Features

icon12

Deletes only the selected features

New column

icon13

Inserts a new column (field) at the end of the attribute table. A field name and a data type must be defined.

Delete column

icon14

Deletes the selected column(s)

Open field calculator

icon15

Opens the field calculator


Fig. 87. Editing attributes in QGIS.

figure087


Fig. 88. Function Count Points in Polygon in QGIS.

figure088

 

7.4.5.2. Table manager plugin

The BEEBOOK