QGIS-06 3.28: QGIS Data Creation and Editing

6. QGIS Data Creation and Editing

This module looks at creating and editing vector data, including both editing geometry in the map window, and editing attribute data in the attribute table and forms. 

6.1. Create a New Layer

Until now, we have been working with existing data. In this exercise we will create a new layer from scratch - in this case it’s a GeoPackage, but the process for other formats is similar.

6.1.1. Create a layer

  1. Open the QGIS Training > Essentials > essentials_05_datacreation project

  2. Create a new layer using Data Source Manager Toolbar > New GeoPackage Layer with the following settings:

    1. Database: QGIS Training > Data > vector [your filename]

    2. Table name: [your layer name]

    3. Geometry type: Polygon

  3. In New Field, add fields (attributes) as follows, clicking Add to Fields List after each one:

    1. description (text)

    2. date (date)

    3. reference (integer)

  4. When you have populated the Fields List with the new fields, click OK to save the layer

  5. Activate the Digitizing Toolbar, then with the new layer highlighted, Toggle Editing for the layer

  6. Using the Add Polygon Feature button, create a new feature in the layer by clicking where you want each point in the polygon to appear, then right-click to finish

  7. Populate the attribute values when prompted

  8. Click OK to complete the feature, then add one or two more features

  9. When you are done, click the Save button on the Digitizing Toolbar to save your edits

  10. Open the attribute table for the layer, and make further edits to attribute values

  11. Save again, then Toggle Editing off

Note that:

  • Edits are not saved to their source until you save them - use the Save Layer Edits button to do this (you will be prompted to save when you use the Toggle Editing button to stop editing)

  • Ctrl-Z (undo) will reverse the last change you made, as long as you have not saved your edits

6.2. Edit Feature Geometry

Once you have created features, you may want to edit their geometry. You can do this by adding, deleting or moving individual vertices (aka nodes), which are the points which make up all features, whether they are lines, polygons or just points.

6.2.1. Modify geometry

  1. Load a polygon layer - for example aonb_england

  2. Turn on editing for the layer using the Toggle Editing button

  3. Select the Vertex Tool in the Digitizing Toolbar

  4. Hover over the feature you want to edit - the vertices will be highlighted as small red circles (zoom in closer if you need to)

  5. To edit vertices, use the following guide:

    1. move a vertex: click on a vertex and move the mouse to its new position, and click again

    2. delete a vertex: click on a vertex, then click the Delete key

    3. delete multiple vertices: click and drag a rectangle over the nodes to be deleted, then click Delete

    4. move a segment of a line or polygon between vertices: click the segment to select it, move the mouse to its new position, click again

    5. create a new vertex: click on the X which appears between two existing vertices, move the mouse to the desired position, then click again

  6. When you have finished, save your edits and save the project

6.2.2. Vertex tips

  • To delete the last vertex you created, use Backspace

  • If you double-click when digitising, two nodes will be created on top of each other – try not to do this

  • Right-click on a vertex to show the Vertex Editor, which displays the coordinates of each vertex

6.3. Snapping

Snapping allows you to create new features, or move existing ones, to align exactly with the coordinates of another feature - for example to create a new boundary or building footprint which abuts or encloses an existing one. When snapping is activated, any new vertices you create will snap to the coordinates of an existing vertex in the target layer if you click within the tolerance settings.

6.3.1. Edit using snapping

  1. Open the essentials_03_styling project

  2. Activate the Snapping Toolbar

  3. In the toolbar, click the Activate Snapping button (far left)

  4. Click the next button - All Layers - and select Open Snapping Options

  5. Click All Layers again, and change the dropdown to Advanced Configuration - you should see a dialog like this

  6. Check the box to the left of crime_bristol_202210 - neighbourhood_crimes, and set a Tolerance of 20 pixels

  7. Toggle editing for this layer, then add a feature - you will see that when you move the cursor within the tolerance settings of an existing vertex, it shows a purple square, indicating that you are within snapping range

  8. Change the tolerance setting if you find it’s too large or small

  9. If you click to create a vertex while the purple square layer is showing, the new vertex will be created at exactly the same position as the vertex indicated by the square

  10. Save your edits to create the new feature

Note that snapping settings stay in place until you change them or turn off snapping.

6.4. Tracing

As well as snapping, you can go one step further and trace features - i.e. replicate some or all the points on a line or polygon in a new feature, to avoid snapping to each individually.

6.4.1. Edit with tracing

  1. In the Snapping Toolbar, click Enable Tracing

  2. Move the cursor over the first vertex you want to trace from and click

  3. Move the cursor over the last vertex of the section you want to trace, and click

  4. All the points on the polygon in between your clicks will be digitised, and you can continue creating vertices to create your new polygon

  5. You can trace from the layer you are creating features in, or a different layer - you will need to ensure that any layer you want to trace over is turned on in the Project Snapping Settings