QGIS Data Creation and Editing This 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. Create a New LayerUntil 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. Create a layerOpen the QGIS Training > Essentials > essentials_05_datacreation project Create a new layer using Data Source Manager Toolbar > New GeoPackage Layer with the following settings: Database: QGIS Training > Data > vector [your filename] Table name: [your layer name] Geometry type: Polygon
In New Field, add fields (attributes) as follows, clicking Add to Fields List after each one: description (text) date (date) reference (integer)
When you have populated the Fields List with the new fields, click OK to save the layer Activate the Digitizing Toolbar, then with the new layer highlighted, Toggle Editing for the layer 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 Populate the attribute values when prompted Click OK to complete the feature, then add one or two more features When you are done, click the Save button on the Digitizing Toolbar to save your edits Open the attribute table for the layer, and make further edits to attribute values 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
Edit Feature GeometryOnce 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. Modify geometryLoad a polygon layer - for example aonb_england Turn on editing for the layer using the Toggle Editing button Select the Vertex Tool in the Digitizing Toolbar Hover over the feature you want to edit - the vertices will be highlighted as small red circles (zoom in closer if you need to) To edit vertices, use the following guide: move a vertex: click on a vertex and move the mouse to its new position, and click again delete a vertex: click on a vertex, then click the Delete key delete multiple vertices: click and drag a rectangle over the nodes to be deleted, then click Delete 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 create a new vertex: click on the X which appears between two existing vertices, move the mouse to the desired position, then click again
When you have finished, save your edits and save the project
Vertex tipsTo 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
SnappingSnapping 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. Edit using snappingOpen the essentials_03_styling project Activate the Snapping Toolbar In the toolbar, click the Activate Snapping button (far left)
Click the next button - All Layers - and select Open Snapping Options Click All Layers again, and change the dropdown to Advanced Configuration - you should see a dialog like this
Check the box to the left of crime_bristol_202210 - neighbourhood_crimes, and set a Tolerance of 20 pixels 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 Change the tolerance setting if you find it’s too large or small 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 Save your edits to create the new feature
Note that snapping settings stay in place until you change them or turn off snapping. TracingAs 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. Edit with tracingIn the Snapping Toolbar, click Enable Tracing Move the cursor over the first vertex you want to trace from and click Move the cursor over the last vertex of the section you want to trace, and click All the points on the polygon in between your clicks will be digitised, and you can continue creating vertices to create your new polygon 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
|