14.5. Editing

QGIS has various capabilities for editing OGR, SpatiaLite, PostGIS, MSSQL Spatial and Oracle Spatial vector layers and tables.

Muista

The procedure for editing GRASS layers is different - see section Digitizing and editing a GRASS vector layer for details.

Vihje

Concurrent Edits

This version of QGIS does not track if somebody else is editing the same feature at the same time as you are. The last person to save the edits wins.

14.5.1. Setting the Snapping Tolerance and Search Radius

For optimal and accurate editing of vector layer geometries, we need to set an appropriate value of snapping tolerance and search radius for features vertices.

14.5.1.1. Snapping tolerance

When you add a new vertex or move an existing one, the snapping tolerance is the distance QGIS uses to search for the closest vertex or segment you are trying to connect to. If you are not within the snapping tolerance, QGIS will leave the vertex where you release the mouse button, instead of snapping it to an existing vertex or segment.

The snapping tolerance setting affects all tools that work with tolerance.

You can enable / disable snapping by using the snapping Enable snapping button on the Snapping Toolbar or pressing s. The snapping mode, tolerance value, and units can also be configured in this toolbar.

The snapping configuration can also be set in Project ► Snapping Options….

There are three options to select the layer(s) to snap to:

  • All layers: quick setting for all visible layers in the project so that the pointer snaps to all vertices and/or segments. In most cases, it is sufficient to use this snapping mode, but beware when using it for projects with many vector layers, as it may affect performance.

  • Current layer: only the active layer is used, a convenient way to ensure topological consistency within the layer being edited.

  • Advanced Configuration: allows you to enable and adjust snapping mode and tolerance on a layer basis (see Fig. 14.84). If you need to edit a layer and snap its vertices to another, make sure that the target layer is checked and increase the snapping tolerance to a higher value. Snapping will not occur to a layer that is not checked in the snapping options dialog.

As for snapping mode, you can choose between To vertex, To segment, and To vertex and segment.

The tolerance values can be set either in the project’s map units or in pixels. The advantage of choosing pixels is that it keeps the snapping constant at different map scales. 10 to 12 pixels is normally a good value, but it depends on the DPI of your screen. Using map units allows the tolerance to be related to real ground distances. For example, if you have a minimum distance between elements, this option can be useful to ensure that you don’t add vertices too close to each other.

../../../_images/editProjectSnapping.png

Fig. 14.84 Snapping options (Advanced Configuration mode)

Muista

By default, only visible features (the features whose style is displayed, except for layers where the symbology is ”No symbols”) can be snapped. You can enable the snapping on invisible features by checking unchecked Enable snapping on invisible features under the Settings ► Options ► Digitizing tab.

Vihje

Enable snapping by default

You can set snapping to be enabled by default on all new projects in the Settings ► Options ► Digitizing tab. You can also set the default snapping mode, tolerance value, and units, which will populate the Snapping Options dialog.

14.5.1.2. Enable snapping on intersections

Another available option is to use snappingIntersection snapping on intersection, which allows you to snap to geometry intersections of snapping enabled layers, even if there are no vertices at the intersections.

14.5.1.3. Snapping icons

QGIS will show different snap icons depending on the kind of snap:

../../../_images/snap_vertex_icon.png
../../../_images/snap_segment_icon.png
../../../_images/snap_intersection_icon.png

Snapping to a vertex: box icon

Snapping to a segment: hourglass icon

Snapping to an intersection: cross icon

Note that it is possible to change the color of these icons in the Digitizing part of your settings.

14.5.1.4. Search radius

Search radius for vertex edits is the distance QGIS uses to search for the vertex to select when you click on the map. If you are not within the search radius, QGIS will not find and select any vertex for editing. The search radius for vertex edits can be defined under the Settings ► options Options ► Digitizing tab (this is where you define the snapping default values).

Snap tolerance and search radius are set in map units or pixels. You may need to experiment to get them right. If you specify a too big tolerance, QGIS may snap to the wrong vertex, especially if you are dealing with a large number of vertices in close proximity. The smaller the search radius, the more difficult it will be to hit what you want to move.

14.5.1.5. Limit snapping to a scale range

In some cases snapping can become very slow. This is often caused by the amount of features in some layers that require a heavy index to compute and maintain. Some parameters exist to enable snapping only when the map view is inside a relevant scale range. This allows to only do the costly index computation related to snapping at a scale where drawing is relevant.

Scale limit to snapping is configured in Project ► Snapping Options…. Limiting snapping to scale is only available in Advanced Configuration mode.

To limit snapping to a scale range you have three modes available:

  • Disabled: Snapping is enabled whatever the current map scale is. This is the default mode.

  • Global: Snapping is limited and only enabled when the current scale of the map is between a global minimum and a global maximum value. When selecting this mode two widgets become available to configure the range of scales in which snapping is enabled.

  • Per layer: The snapping scale range limit is defined for each layer. When selecting this mode two columns become available to configure the minimum and maximum scales for each layer.

Please note that the minimum and maximum scales follow the QGIS convention: minimum scale is the most ”zoomed out” scale while maximum scale is the most ”zoomed in”. A minimum or maximum scale that is set to ”0” or ”not set” is considered not limiting.

14.5.2. Topological editing

In addition to these snapping options, the Snapping options… dialog (Project ► Snapping options) and the Snapping toolbar allow you to enable / disable some other topological functionalities.

14.5.2.1. Enable topological editing

The topopologicalEditing Topological editing button helps when editing and maintaining features with common boundaries. With this option enabled, QGIS ’detects’ shared boundaries. When you move common vertices/segments, QGIS will also move them in the geometries of the neighboring features.

Topological editing works with features from different layers, as long as the layers are visible and in editing mode.

14.5.2.2. Avoid overlap of new polygons

When the snapping mode is set to Advanced configuration, for polygon layers, there’s an option called checkbox Avoid overlap. This option prevents you from drawing new features that overlap existing ones in the selected layer, speeding up digitizing of adjacent polygons.

With avoid overlap enabled, if you already have one polygon, you can digitize a second one such that they intersect. QGIS will then cut the second polygon to the boundary of the existing one. The advantage is that you don’t have to digitize all vertices of the common boundary.

Muista

If the new geometry is totally covered by existing ones, it gets cleared, and QGIS will show an error message.

Varoitus

Use cautiously the Avoid overlap option

Since this option will cut new overlapping geometries of any polygon layer, you can get unexpected geometries if you forget to uncheck it when no longer needed.

14.5.2.3. Geometry Checker

A core plugin can help the user to find the geometry invalidity. You can find more information on this plugin at Geometry Checker Plugin.

14.5.2.4. Automatic Tracing

Usually, when using capturing map tools (add feature, add part, add ring, reshape and split), you need to click each vertex of the feature. With the automatic tracing mode, you can speed up the digitization process as you no longer need to manually place all the vertices during digitization:

  1. Enable the tracing Tracing tool (in the Snapping toolbar) by pushing the icon or pressing T key.

  2. Snap to a vertex or segment of a feature you want to trace along.

  3. Move the mouse over another vertex or segment you’d like to snap and, instead of the usual straight line, the digitizing rubber band represents a path from the last point you snapped to the current position. The tool also works with curved geometries.

    QGIS actually uses the underlying features topology to build the shortest path between the two points. Tracing requires snapping to be activated in traceable layers to build the path. You should also snap to an existing vertex or segment while digitizing and ensure that the two nodes are topologically connectable through existing features edges, otherwise QGIS is unable to connect them and thus traces a single straight line.

  4. Click and QGIS places the intermediate vertices following the displayed path.

Unfold the tracing Enable Tracing icon and set the Offset option to digitize a path parallel to the features instead of tracing along them. A positive value shifts the new drawing to the left side of the tracing direction and a negative value does the opposite.

Muista

Adjust map scale or snapping settings for an optimal tracing

If there are too many features in map display, tracing is disabled to avoid potentially long tracing structure preparation and large memory overhead. After zooming in or disabling some layers the tracing is enabled again.

Muista

Does not add topological points

This tool does not add points to existing polygon geometries even if Topological editing is enabled. If geometry precision is activated on the edited layer, the resulting geometry might not exactly follow an existing geometry.

Vihje

Quickly enable or disable automatic tracing by pressing the T key

By pressing the T key, tracing can be enabled/disabled anytime (even while digitizing a feature), so it is possible to digitize parts of the feature with tracing enabled and other parts with tracing disabled. Tools behave as usual when tracing is disabled.

Vihje

Convert tracing to curved geometries

By using Settings ► Options ► Digitizing ► Tracing you can create curved geometries while digitizing. See digitizing options.

14.5.3. Digitizing an existing layer

By default, QGIS loads layers read-only. This is a safeguard to avoid accidentally editing a layer if there is a slip of the mouse. However, you can choose to edit any layer as long as the data provider supports it (see Exploring Data Formats and Fields), and the underlying data source is writable (i.e., its files are not read-only).

Vihje

Restrict edit permission on layers within a project

From the Project ► Properties… ► Data Sources ► Layers Capabilities table, you can choose to set any layer read-only regardless the provider permission. This can be a handy way, in a multi-users environment to avoid unauthorized users to mistakenly edit layers (e.g., Shapefile), hence potentially corrupt data. Note that this setting only applies inside the current project.

In general, tools for editing vector layers are divided into a digitizing and an advanced digitizing toolbar, described in section Advanced digitizing. You can select and unselect both under View ► Toolbars ►.

Using the basic digitizing tools, you can perform the following functions:

Icon

Purpose

Icon

Purpose

allEdits

Current edits

toggleEditing

Toggle editing

saveEdits

Save layer edits

newTableRow

Add new record

capturePoint

Add Feature: Capture Point

captureLine

Add Feature: Capture Line

capturePolygon

Add Feature: Capture Polygon

vertexTool

Vertex Tool (All Layers)

vertexToolActiveLayer

Vertex Tool (Current Layer)

multiEdit

Modify the attributes of all selected features simultaneously

deleteSelectedFeatures

Delete Selected

editCut

Cut Features

editCopy

Copy Features

editPaste

Paste Features

undo

Undo

redo

Redo

Table Editing: Vector layer basic editing toolbar

Note that while using any of the digitizing tools, you can still zoom or pan in the map canvas without losing the focus on the tool.

All editing sessions start by choosing the toggleEditing Toggle editing option found in the context menu of a given layer, from the attribute table dialog, the digitizing toolbar or the Edit menu.

Once the layer is in edit mode, additional tool buttons on the editing toolbar will become available and markers will appear at the vertices of all features unless Show markers only for selected features option under Settings ► Options… ► Digitizing menu is checked.

Vihje

Save Regularly

Remember to saveEdits Save Layer Edits regularly. This will also check that your data source can accept all the changes.

14.5.3.1. Adding Features

Depending on the layer type, you can use the newTableRow Add Record, capturePoint Add Point Feature, captureLine Add Line Feature or capturePolygon Add Polygon Feature icons on the toolbar to add new features into the current layer.

To add a geometryless feature, click on the newTableRow Add Record button and you can enter attributes in the feature form that opens. To create features with the spatially enabled tools, you first digitize the geometry then enter its attributes. To digitize the geometry:

  1. Left-click on the map area to create the first point of your new feature. For point features, this should be enough and trigger, if required, the feature form to fill in their attributes. Having set the geometry precision in the layer properties you can use snap to grid here to create features based on a regular distance.

  2. For line or polygon geometries, keep on left-clicking for each additional point you wish to capture or use automatic tracing capability to accelerate the digitization. This will create consecutive straight lines between the vertices you place.

    Muista

    Pressing Delete or Backspace key reverts the last node you add.

  3. When you have finished adding points, right-click anywhere on the map area to confirm you have finished entering the geometry of that feature.

    Muista

    While digitizing line or polygon geometries, you can switch back and forth between the linear Add feature tools and circular string tools to create compound curved geometries.

    Vihje

    Customize the digitizing rubber band

    While capturing polygon, the by-default red rubber band can hide underlying features or places you’d like to capture a point. This can be fixed by setting a lower opacity (or alpha channel) to the rubber band’s Fill Color in Settings ► Options ► Digitizing menu. You can also avoid the use of the rubber band by checking Don’t update rubber band during node editing.

  4. The attribute window will appear, allowing you to enter the information for the new feature. Fig. 14.85 shows setting attributes for a fictitious new river in Alaska. However, in the Digitizing menu under the Settings ► Options menu, you can also activate:

    • checkbox Suppress attributes pop-up windows after each created feature to avoid the form opening;

    • or checkbox Reuse last entered attribute values to have fields automatically filled at the opening of the form and just have to type changing values.

../../../_images/editDigitizing.png

Fig. 14.85 Enter Attribute Values Dialog after digitizing a new vector feature

14.5.3.2. Vertex tool

Muista

QGIS 3 major changes

In QGIS 3, the node tool has been fully redesigned and renamed to vertex tool. It was previously working with ”click and drag” ergonomy, and now uses a ”click - click” workflow. This allows major improvements like taking profit of the advanced digitizing panel with the vertex tool while digitizing or editing objects of multiple layers at the same time.

For any editable vector layer, the vertexToolActiveLayer Vertex tool (Current Layer) provides manipulation capabilities of feature vertices similar to CAD programs. It is possible to simply select multiple vertices at once and to move, add or delete them altogether. The vertex tool also supports the topological editing feature. This tool is selection persistent, so when some operation is done, selection stays active for this feature and tool.

It is important to set the property Settings ► options Options ► Digitizing ► Search Radius: selectNumber to a number greater than zero. Otherwise, QGIS will not be able to tell which vertex is being edited and will display a warning.

Vihje

Vertex Markers

The current version of QGIS supports three kinds of vertex markers: ’Semi-transparent circle’, ’Cross’ and ’None’. To change the marker style, choose options Options from the Settings menu, click on the Digitizing tab and select the appropriate entry.

Basic operations

Start by activating the vertexToolActiveLayer Vertex Tool (Current Layer). Red circles will appear when hovering vertices.

  • Selecting vertices: You can select vertices by clicking on them one at a time holding Shift key pressed, or by clicking and dragging a rectangle around some vertices. When a vertex is selected, its color changes to blue. To add more vertices to the current selection, hold down the Shift key while clicking. To remove vertices from the selection, hold down Ctrl.

  • Batch vertex selection mode: The batch selection mode can be activated by pressing Shift+R. Select a first node with one single click, and then hover without clicking another vertex. This will dynamically select all the nodes in between using the shortest path (for polygons).

    ../../../_images/vertex_batch_selection_mode.png

    Fig. 14.86 Batch vertex selection using Shift+R

    Press Ctrl will invert the selection, selecting the longest path along the feature boundary. Ending your node selection with a second click, or pressing Esc will escape the batch mode.

  • Adding vertices: To add a vertex, a virtual new node appears on the segment center. Simply grab it to add a new vertex. A double-click on any location of the boundary also creates a new node. For lines, a virtual node is also proposed at both extremities of a line to extend it.

    ../../../_images/vertex_add_node.png

    Fig. 14.87 Virtual nodes for adding vertices

  • Deleting vertices: Select the vertices and click the Delete key. Deleting all the vertices of a feature generates, if compatible with the datasource, a geometryless feature. Note that this doesn’t delete the complete feature, just the geometry part. To delete a complete feature use the deleteSelectedFeatures Delete Selected tool.

  • Moving vertices: Select all the vertices you want to move, click on a selected vertex or edge, and click again on the desired new location. All the selected vertices will move together. If snapping is enabled, the whole selection can jump to the nearest vertex or line. You can use Advanced Digitizing Panel constraints for distance, angles, exact X Y location before the second click.

    Here you can use the snap-to-grid feature. Having set a value for the geometry precision in the layer properties, a grid appears on a zoom level according to the Geometry precision.

    ../../../_images/vertex_snap_to_grid.png

    Fig. 14.88 Selecting a vertex and moving the vertices to grid

Each change made with the vertex is stored as a separate entry in the Undo dialog. Remember that all operations support topological editing when this is turned on. On-the-fly projection is also supported, and the vertex tool provides tooltips to identify a vertex by hovering the pointer over it.

The Vertex Editor Panel

When using the Vertex tool on a feature, it is possible to right click to open the Vertex Editor panel listing all the vertices of the feature with their x, y (z, m if applicable) coordinates and r (for the radius, in case of circular geometry). Simply select a row in the table does select the corresponding vertex in the map canvas, and vice versa. Simply change a coordinate in the table and your vertex position is updated. You can also select multiple rows and delete them altogether.

Muista

Changed behavior in QGIS 3.4

Right click on a feature will immediately show the vertex editor and lock this feature, thus disabling the editing of any other features. While being locked, a feature is exclusive for editing: Selecting and moving of vertices and segments by clicking or dragging is only possible for this feature. New vertices can only be added to the locked feature. Also, the vertex editor panel now opens itself automatically upon activating the vertex tool, and its position/docked state remembered across uses.

../../../_images/vertex_editor_panel.png

Fig. 14.89 Vertex editor panel showing selected nodes

14.5.3.3. Cutting, Copying and Pasting Features

Selected features can be cut, copied and pasted between layers in the same QGIS project, as long as destination layers are set to toggleEditing Toggle editing beforehand.

Vihje

Transform polygon into line and vice-versa using copy/paste

Copy a line feature and paste it in a polygon layer: QGIS pastes in the target layer a polygon whose boundary corresponds to the closed geometry of the line feature. This is a quick way to generate different geometries of the same data.

Features can also be pasted to external applications as text. That is, the features are represented in CSV format, with the geometry data appearing in the OGC Well-Known Text (WKT) format. WKT and GeoJSON features from outside QGIS can also be pasted to a layer within QGIS.

When would the copy and paste function come in handy? Well, it turns out that you can edit more than one layer at a time and copy/paste features between layers. Why would we want to do this? Say we need to do some work on a new layer but only need one or two lakes, not the 5,000 on our big_lakes layer. We can create a new layer and use copy/paste to plop the needed lakes into it.

As an example, we will copy some lakes to a new layer:

  1. Load the layer you want to copy from (source layer)

  2. Load or create the layer you want to copy to (target layer)

  3. Start editing for target layer

  4. Make the source layer active by clicking on it in the legend

  5. Use the selectRectangle Select Features by area or single click tool to select the feature(s) on the source layer

  6. Click on the editCopy Copy Features tool

  7. Make the destination layer active by clicking on it in the legend

  8. Click on the editPaste Paste Features tool

  9. Stop editing and save the changes

What happens if the source and target layers have different schemas (field names and types are not the same)? QGIS populates what matches and ignores the rest. If you don’t care about the attributes being copied to the target layer, it doesn’t matter how you design the fields and data types. If you want to make sure everything - the feature and its attributes - gets copied, make sure the schemas match.

Muista

Congruency of Pasted Features

If your source and destination layers use the same projection, then the pasted features will have geometry identical to the source layer. However, if the destination layer is a different projection, then QGIS cannot guarantee the geometry is identical. This is simply because there are small rounding-off errors involved when converting between projections.

Vihje

Copy string attribute into another

If you have created a new column in your attribute table with type ’string’ and want to paste values from another attribute column that has a greater length the length of the column size will be extended to the same amount. This is because the GDAL Shapefile driver starting with GDAL/OGR 1.10 knows to auto-extend string and integer fields to dynamically accommodate for the length of the data to be inserted.

14.5.3.4. Deleting Selected Features

If we want to delete an entire feature (attribute and geometry), we can do that by first selecting the geometry using the regular selectRectangle Select Features by area or single click tool. Selection can also be done from the attribute table. Once you have the selection set, press Delete or Backspace key or use the deleteSelectedFeatures Delete Selected tool to delete the features. Multiple selected features can be deleted at once.

The editCut Cut Features tool on the digitizing toolbar can also be used to delete features. This effectively deletes the feature but also places it on a ”spatial clipboard”. So, we cut the feature to delete. We could then use the editPaste Paste Features tool to put it back, giving us a one-level undo capability. Cut, copy, and paste work on the currently selected features, meaning we can operate on more than one at a time.

14.5.3.5. Undo and Redo

The undo Undo and redo Redo tools allows you to undo or redo vector editing operations. There is also a dockable widget, which shows all operations in the undo/redo history (see Fig. 14.90). This widget is not displayed by default; it can be displayed by right-clicking on the toolbar and activating the Undo/Redo Panel checkbox. The Undo/Redo capability is however active, even if the widget is not displayed.

../../../_images/redo_undo.png

Fig. 14.90 Redo and Undo digitizing steps

When Undo is hit or Ctrl+Z (or Cmd+Z) pressed, the state of all features and attributes are reverted to the state before the reverted operation happened. Changes other than normal vector editing operations (for example, changes done by a plugin) may or may not be reverted, depending on how the changes were performed.

To use the undo/redo history widget, simply click to select an operation in the history list. All features will be reverted to the state they were in after the selected operation.

14.5.3.6. Saving Edited Layers

When a layer is in editing mode, any changes remain in the memory of QGIS. Therefore, they are not committed/saved immediately to the data source or disk. If you want to save edits to the current layer but want to continue editing without leaving the editing mode, you can click the saveEdits Save Layer Edits button. When you turn editing mode off with toggleEditing Toggle editing (or quit QGIS for that matter), you are also asked if you want to save your changes or discard them.

If the changes cannot be saved (e.g., disk full, or the attributes have values that are out of range), the QGIS in-memory state is preserved. This allows you to adjust your edits and try again.

Vihje

Data Integrity

It is always a good idea to back up your data source before you start editing. While the authors of QGIS have made every effort to preserve the integrity of your data, we offer no warranty in this regard.

Saving multiple layers at once

This feature allows the digitization of multiple layers. Choose fileSaveAs Save for Selected Layers to save all changes you made in multiple layers. You also have the opportunity to rollbackEdits Rollback for Selected Layers, so that the digitization may be withdrawn for all selected layers. If you want to stop editing the selected layers, cancelEdits Cancel for Selected Layer(s) is an easy way.

The same functions are available for editing all layers of the project.

Vihje

Use transaction group to edit, save or rollback multiple layers changes at once

When working with layers from the same PostGreSQL database, activate the Automatically create transaction groups where possible option in Project ► Properties… ► Data Sources to sync their behavior (enter or exit the edit mode, save or rollback changes at the same time).

14.5.4. Advanced digitizing

Icon

Purpose

Icon

Purpose

cad

Enable Advanced Digitizing Tools

tracing

Enable Tracing

moveFeature moveFeatureLine moveFeaturePoint

Move Feature(s)

moveFeatureCopy moveFeatureCopyLine moveFeatureCopyPoint

Copy and Move Feature(s)

rotateFeature

Rotate Feature(s)

simplifyFeatures

Simplify Feature

addRing

Add Ring

addPart

Add Part

fillRing

Fill Ring

reverseLine

Swap direction

deleteRing

Delete Ring

deletePart

Delete Part

offsetCurve

Offset Curve

reshape

Reshape Features

splitParts

Split Parts

splitFeatures

Split Features

mergeFeatAttributes

Merge Attributes of Selected Features

mergeFeatures

Merge Selected Features

rotatePointSymbols

Rotate Point Symbols

offsetPointSymbols

Offset Point Symbols

trimExtend

Trim or Extend Feature

Table Advanced Editing: Vector layer advanced editing toolbar

14.5.4.1. Move Feature(s)

The moveFeature Move Feature(s) tool allows you to move existing features:

  1. Select the feature(s) to move.

  2. Click on the map canvas to indicate the origin point of the displacement; you can rely on snapping capabilities to select an accurate point.

    You can also take advantages of the advanced digitizing constraints to accurately set the origin point coordinates. In that case:

    1. First click on the cad button to enable the panel.

    2. Type x and enter the corresponding value for the origin point you’d like to use. Then press the locked button next to the option to lock the value.

    3. Do the same for the y coordinate.

    4. Click on the map canvas and your origin point is placed at the indicated coordinates.

  3. Move over the map canvas to indicate the destination point of the displacement, still using snapping mode or, as above, use the advanced digitizing panel which would provide complementary distance and angle placement constraints to place the end point of the translation.

  4. Click on the map canvas: the whole features are moved to new location.

Likewise, you can create a translated copy of the feature(s) using the moveFeatureCopy Copy and Move Feature(s) tool.

Muista

If no feature is selected when you first click on the map canvas with any of the Move Feature(s) or Copy and Move Feature(s) tools, then only the feature under the mouse is affected by the action. So, if you want to move several features, they should be selected first.

14.5.4.2. Rotate Feature(s)

Use the rotateFeature Rotate Feature(s) tool to rotate one or multiple features in the map canvas:

  1. Press the rotateFeature Rotate Feature(s) icon

  2. Then click on the feature to rotate. The feature’s centroid is referenced as rotation center, a preview of the rotated feature is displayed and a widget opens showing the current Rotation angle.

  3. Click on the map canvas when you are satisfied with the new placement or manually enter the rotation angle in the text box. You can also use the Snap to ° box to constrain the rotation values.

  4. If you want to rotate several features at once, they shall be selected first, and the rotation is by default around the centroid of their combined geometries.

You can also use an anchor point different from the default feature centroid: press the Ctrl button, click on the map canvas and that point will be used as the new rotation center.

If you hold Shift before clicking on the map, the rotation will be done in 45 degree steps, which can be modified afterwards in the user input widget.

To abort feature rotation, press the ESC button or click on the rotateFeature Rotate Feature(s) icon.

14.5.4.3. Simplify Feature

The simplifyFeatures Simplify Feature tool allows you to interactively reshape a line or polygon geometry by reducing or densifying the number of vertices, as long as the geometry remains valid:

  1. Select the simplifyFeatures Simplify Feature tool.

  2. Click on the feature or drag a rectangle over the features.

  3. A dialog pops up allowing you to define the Method to apply, ie whether you would like to:

    • simplify the geometry, meaning less vertices than the original. Available methods are Simplify by distance, Simplify by snapping to grid or simplify by area (Visvalingam). You’d then need to indicate the value of Tolerance in Layer units, Pixels or map units to use for simplification. The higher the tolerance is the more vertices can be deleted.

    • or densify the geometries with new vertices thanks to the Smooth option: for each existing vertex, two vertices are placed on each of the segments originated from it, at an Offset distance representing the percentage of the segment length. You can also set the number of Iterations the placement would be processed: the more iterations, the more vertices and smoother is the feature.

    Settings that you used will be saved when leaving a project or an edit session. So you can go back to the same parameters the next time you simplify a feature.

  4. A summary of the modifications that would apply is shown at the bottom of the dialog, listing number of features and number of vertices (before and after the operation and the ratio the change represents). Also, in the map canvas, the expected geometry is displayed over the existing one, using the rubberband color.

  5. When the expected geometry fits your needs, click OK to apply the modification. Otherwise, to abort the operation, you can either press Cancel or right-click in the map canvas.

Muista

Unlike the feature simplification option in Settings ► Options ► Rendering menu which simplifies the geometry just for rendering, the simplifyFeatures Simplify Feature tool permanently modifies feature’s geometry in data source.

14.5.4.4. Add Part

You can addPart Add Part to a selected feature generating a multipoint, multiline or multipolygon feature. The new part must be digitized outside the existing one which should be selected beforehand.

The addPart Add Part can also be used to add a geometry to a geometryless feature. First, select the feature in the attribute table and digitize the new geometry with the addPart Add Part tool.

14.5.4.5. Delete Part

The deletePart Delete Part tool allows you to delete parts from multifeatures (e.g., to delete polygons from a multi-polygon feature). This tool works with all multi-part geometries: point, line and polygon. Furthermore, it can be used to totally remove the geometric component of a feature. To delete a part, simply click within the target part.

14.5.4.6. Add Ring

You can create ring polygons using the addRing Add Ring icon in the toolbar. This means that inside an existing area, it is possible to digitize further polygons that will occur as a ’hole’, so only the area between the boundaries of the outer and inner polygons remains as a ring polygon.

14.5.4.7. Fill Ring

The fillRing Fill Ring tool helps you create polygon feature that totally falls within another one without any overlapping area; that is the new feature covers a hole within the existing one. To create such a feature:

  1. Select the fillRing Fill Ring tool.

  2. Draw a new polygon over the existing feature: QGIS adds a ring to its geometry (like if you used the addRing Add Ring tool) and creates a new feature whose geometry matches the ring (like if you traced over the interior boundaries with the capturePolygon Add polygon feature tool).

  3. Or alternatively, if the ring already exists on the feature, place the mouse over the ring and left-click while pressing Shift: a new feature filling the hole is drawn at that place.

    The Feature Attributes form of the new feature opens, pre-filled with values of the ”parent” feature and/or fields constraints.

14.5.4.8. Delete Ring

The deleteRing Delete Ring tool allows you to delete rings within an existing polygon, by clicking inside the hole. This tool only works with polygon and multi-polygon features. It doesn’t change anything when it is used on the outer ring of the polygon.

14.5.4.9. Reshape Features

You can reshape line and polygon features using the reshape Reshape Features tool on the toolbar. For lines, it replaces the line part from the first to the last intersection with the original line.

../../../_images/reshape_lines.png

Fig. 14.91 Reshape line

Vihje

Extend linestring geometries with reshape tool

Use the reshape Reshape Features tool to extend existing linestring geometries: snap to the first or last vertex of the line and draw a new one. Validate and the feature’s geometry becomes the combination of the two lines.

For polygons, it will reshape the polygon’s boundary. For it to work, the reshape tool’s line must cross the polygon’s boundary at least twice. To draw the line, click on the map canvas to add vertexes. To finish it, just right-click. Like with the lines, only the segment between the first and the last intersections is considered. The reshape line’s segments that are inside the polygon will result in cropping it, where the ones outside the polygon will extend it.

../../../_images/reshape_polygon.png

Fig. 14.92 Reshape polygon

With polygons, reshaping can sometimes lead to unintended results. It is mainly useful to replace smaller parts of a polygon, not for major overhauls, and the reshape line is not allowed to cross several polygon rings, as this would generate an invalid polygon.

Muista

The reshape tool may alter the starting position of a polygon ring or a closed line. So, the point that is represented ’twice’ will not be the same any more. This may not be a problem for most applications, but it is something to consider.

14.5.4.10. Offset Curves

The offsetCurve Offset Curve tool creates parallel shifts of line layers. The tool can be applied to the edited layer (the geometries are modified) or also to background layers (in which case it creates copies of the lines / rings and adds them to the edited layer). It is thus ideally suited for the creation of distance line layers. The User Input dialog pops-up, showing the displacement distance.

To create a shift of a line layer, you must first go into editing mode and activate the offsetCurve Offset Curve tool. Then click on a feature to shift it. Move the mouse and click where wanted or enter the desired distance in the user input widget. Your changes may then be saved with the saveEdits Save Layer Edits tool.

QGIS options dialog (Digitizing tab then Curve offset tools section) allows you to configure some parameters like Join style, Quadrant segments, Miter limit.

14.5.4.11. Reverse Line

Changing the direction of a line geometry can be useful for cartographical purposes or when preparing for network analysis.

To change a line direction:

  1. Activate the reverse line tool by clicking reverseLine Reverse line.

  2. Click on the line. The direction of the line is reversed.

14.5.4.12. Split Features

Use the splitFeatures Split Features tool to split a feature into two or more new and independent features, ie. each geometry corresponding to a new row in the attribute table.

To split line or polygon features:

  1. Select the splitFeatures Split Features tool.

  2. Draw a line across the feature(s) you want to split. If a selection is active, only selected features are split. When set, default values or clauses are applied to corresponding fields and other attributes of the parent feature are by default copied to the new features.

  3. You can then as usually modify any of the attributes of any resulting feature.

Vihje

Split a polyline into new features in one-click

Using the splitFeatures Split Features tool, snap and click on an existing vertex of a polyline feature to split that feature into two new features.

14.5.4.13. Split parts

In QGIS it is possible to split the parts of a multi part feature so that the number of parts is increased. Just draw a line across the part you want to split using the splitParts Split Parts icon.

Vihje

Split a polyline into new parts in one-click

Using the splitParts Split Parts tool, snap and click on an existing vertex of a polyline feature to split the feature into two new polylines belonging to the same feature.

14.5.4.14. Merge selected features

The mergeFeatures Merge Selected Features tool allows you to create a new feature by merging existing ones: their geometries are merged to generate a new one. If features don’t have common boundaries, a multipolygon/multipolyline/multipoint feature is created.

  1. First, select the features you’d like to combine.

  2. Then press the mergeFeatures Merge Selected Features button.

  3. In the new dialog, the Merge line at the bottom of the table shows the attributes of the resulting feature. You can alter any of these values either by:

    • manually replacing the value in the corresponding cell;

    • selecting a row in the table and pressing Take attributes from selected feature to use the values of this initial feature;

    • pressing Skip all fields to use empty attributes;

    • or, expanding the drop down menu at the top of the table, select any of the above options to apply to the corresponding field only. There, you can also choose to aggregate the initial features attributes (Minimum, Maximum, Median, Sum, Count, Concatenation… depending on the type of the field. see Statistical Summary Panel for the full list of functions).

    Muista

    If the layer has default values or clauses present on fields, these are used as the initial value for the merged feature.

  4. Press OK to apply the modifications. A single (multi)feature is created in the layer, replacing the previously selected ones.

14.5.4.15. Merge attributes of selected features

The mergeFeatAttributes Merge Attributes of Selected Features tool allows you to apply same attributes to features without merging their boundaries. The dialog is the same as the Merge Selected Features tool’s except that unlike that tool, selected objects are kept with their geometry while some of their attributes are made identical.

14.5.4.16. Rotate Point Symbols

The rotatePointSymbols Rotate Point Symbols allows you to individually change the rotation of point symbols in the map canvas.

  1. First, you need to indicate the field to store the rotation value in. This is made by assigning a field to the symbol data-defined rotation property:

    1. In the Layer Properties ► Symbology dialog, browse to the symbol editor dialog.

    2. Click the dataDefined Data-defined override widget near the Rotation option of the top Marker level (preferably) of the symbol layers.

    3. Choose a field in the Field Type combobox. Values of this field are hence used to rotate each feature’s symbol accordingly.

      You can also check the Store data in project entry to generate an auxiliary data storage field to control the rotation value.

    Muista

    Make sure that the same field is assigned to all the symbol layers

    Setting the data-defined rotation field at the topmost level of the symbol tree automatically propagates it to all the symbol layers, a prerequisite to perform graphical symbol rotation with the Rotate Point Symbols tool. Indeed, if a symbol layer does not have the same field attached to its rotation property, the tool will not work.

    ../../../_images/rotatepointsymbol.png

    Fig. 14.93 Rotating a point symbol

  2. Then click on a point symbol in the map canvas with the rotatePointSymbols Rotate Point Symbols tool

  3. Move the mouse around. A red arrow with the rotation value will be visualized (see Fig. 14.93). If you hold the Ctrl key while moving, the rotation will be done in 15 degree steps.

  4. When you get the expected angle value, click again. The symbol is rendered with this new rotation and the associated field is updated accordingly.

    You can right-click to abort symbol rotation.

14.5.4.17. Offset Point Symbols

The offsetPointSymbols Offset Point Symbols allows you to interactively change the rendered position of point symbols in the map canvas. This tool behaves like the rotatePointSymbols Rotate Point Symbols tool except that it requires you to connect a field to the data-defined Offset (X,Y) property of each layer of the symbol. The field will then be populated with the offset coordinates for the features whose symbol is moved in the map canvas.

  1. Associate a field to the data-defined widget of the Offset (X,Y) property of the symbol. If the symbol is made with many layers, you may want to assign the field to each of them

  2. Select the offsetPointSymbols Offset Point Symbols tool

  3. Click a point symbol

  4. Move to a new location

  5. Click again. The symbol is moved to the new place. Offset values from the original position are stored in the linked field.

    You can right-click to abort symbol offset.

Muista

The offsetPointSymbols Offset Point Symbols tool doesn’t move the point feature itself; you should use the vertexToolActiveLayer Vertex Tool (Current Layer) or moveFeaturePoint Move Feature tool for this purpose.

14.5.4.18. Trim/Extend Feature

When a digitized line is too short or too long to snap to another line (missing or crossing the line), it is necessary to be able to extend or shorten the segment.

The trimExtend Trim/Extend tool allows you to also modify (multi)lines AND (multi)polygons. Moreover, it is not necessarily the end of the lines that is concerned; any segment of a geometry can be modified.

Muista

This can lead to invalid geometries.

Muista

You must activate segment snapping for this tool to work.

The tool asks you to select a limit (a segment) with respect to which another segment will be extended or trimmed. Unlike the vertex tool, a check is performed to modify only the layer being edited.

When both segments are in 3D, the tool performs an interpolation on the limit segment to get the Z value.

In the case of a trim, you must select the part that will be shortened by clicking on it.

14.5.5. Shape digitizing

The Shape Digitizing toolbar offers a set of tools to draw regular shapes and curved geometries.

14.5.5.1. Add Circular string

The circularStringCurvePoint Add circular string or circularStringRadius Add circular string by radius buttons allow users to add line or polygon features with a circular geometry.

Creating features with these tools follow the same rule as of other digitizing tools: left-click to place vertices and right-click to finish the geometry. While drawing the geometry, you can switch from one tool to the other as well as to the linear geometry tools, creating some coumpound geometries.

Muista

Curved geometries are stored as such only in compatible data provider

Although QGIS allows to digitize curved geometries within any editable data format, you need to be using a data provider (e.g. PostGIS, memory layer, GML or WFS) that supports curves to have features stored as curved, otherwise QGIS segmentizes the circular arcs.

14.5.5.2. Draw Circles

There is a set of tools for drawing circles. The tools are described below.

Circles are converted into circular strings. Therefore, as explained in Add Circular string, if allowed by the data provider, it will be saved as a curved geometry, if not, QGIS will segmentize the circular arcs.

  • circle2Points Add circle from 2 points: The two points define the diameter and the orientation of the circle. (Left-click, right-click)

  • circle3Points Add circle from 3 points: Draws a circle from three known points on the circle. (Left-click, left-click, right-click)

  • circleCenterPoint Add circle from center and a point: Draws a circle with a given center and a point on the circle (Left-click, right-click). When used with the The Advanced Digitizing panel this tool can become a ”Add circle from center and radius” tool by setting and locking the distance value after first click.

  • circle3Tangents Add circle from 3 tangents: Draws a circle that is tangential to three segments. Note that you must activate snapping to segments (See Setting the Snapping Tolerance and Search Radius). Click on a segment to add a tangent. If two tangents are parallel, an error message appears and the input is cleared. (Left-click, left-click, right-click)

  • circle2TangentsPoint Add circle from 2 tangents and a point: Similar to circle from 3 tangents, except that you have to select two tangents, enter a radius and select the desired center.

14.5.5.3. Draw Ellipses

There is a set of tools for drawing ellipses. The tools are described below.

Ellipses cannot be converted as circular strings, so they will always be segmented.

  • ellipseCenter2Points Add Ellipse from center and two points: Draws an ellipse with a given center, major axis and minor axis. (Left-click, left-click, right-click)

  • ellipseCenterPoint Add Ellipse from center and a point: Draws an ellipse into a bounding box with the center and a corner. (Left-click, right-click)

  • ellipseExtent Add Ellipse from extent: Draws an ellipse into a bounding box with two opposite corners. (Left-click, right-click)

  • ellipseFoci Add Ellipse from foci: Draws an ellipse by 2 points for foci and a point on the ellipse. (Left-click, left-click, right-click)

14.5.5.4. Draw Rectangles

There is a set of tools for drawing rectangles. The tools are described below.

  • rectangleCenter Rectangle from center and a point: Draws a rectangle from the center and a corner. (Left-click, right-click)

  • rectangleExtent Rectangle from extent: Draws a rectangle from two opposite corners. (Left-click, right-click)

  • rectangle3PointsDistance Rectangle from 3 points (distance): Draws an oriented rectangle from three points. The first and second points determine the length and angle of the first edge. The third point determines the length of the other edge. One can use The Advanced Digitizing panel to set the length of the edges. (Left-click, left-click, right-click)

  • rectangle3PointsProjected Rectangle from 3 points (projected): Same as the preceding tool, but the length of the second edge is computed from the projection of the third point on the first edge. (Left-click, left-click, right-click)

    ../../../_images/draw_rectangles_3_points.png

    Fig. 14.94 Draw rectangle from 3 points using distance (right) and projected (left)

14.5.5.5. Draw Regular Polygons

There is a set of tools for drawing regular polygons. The tools are described below. Left-click to place the first point. A dialog appears, where you can set the number of polygon edges. Right-click to finish the regular polygon.

  • regularPolygon2Points Regular polygon from two points: Draws a regular polygon where the two points determine the length and angle of the first edge.

  • regularPolygonCenterPoint Regular polygon from center and a point: Draws a regular polygon from the provided center point. The second point determines the angle and distance to the middle of an edge.

  • regularPolygonCenterCorner Regular polygon from center and a corner: Same as the preceding tool, but the second point determines the angle and distante to a vertex.

14.5.6. The Advanced Digitizing panel

When capturing, reshaping, splitting new or existing geometries you also have the possibility to use the Advanced Digitizing panel. You can digitize lines exactly parallel or perpendicular to a particular angle or lock lines to specific angles. Furthermore, you can enter coordinates directly so that you can make a precise definition of your new geometry.

../../../_images/advanced_digitizing.png

Fig. 14.95 The Advanced Digitizing panel

The Advanced Digitizing panel can be open either with a right-click on the toolbar, from View ► Panels ► menu or pressing Ctrl+4. Once the panel is visible, click the cad Enable advanced digitizing tools button to activate the set of tools.

Muista

The tools are not enabled if the map view is in geographic coordinates.

14.5.6.1. Concepts

The aim of the Advanced Digitizing tool is to lock coordinates, lengths, and angles when moving the mouse during the digitalizing in the map canvas.

You can also create constraints with relative or absolute reference. Relative reference means that the next vertex constraints’ values will be relative to the previous vertex or segment.

14.5.6.2. Snapping Settings

Click the settings button to set the Advanced Digitizing Tool snapping settings. You can make the tool snap to common angles. The options are:

  • Do not snap to common angles

  • Snap to 30º angles

  • Snap to 45º angles

  • Snap to 90º angles

You can also control the snapping to features. The options are:

  • Do not snap to vertices or segments

  • Snap according to project configuration

  • Snap to all layers

14.5.6.3. Keyboard shortcuts

To speed up the use of Advanced Digitizing Panel, there are a couple of keyboard shortcuts available:

Key

Simple

Ctrl+ or Alt+

Shift+

D

Set distance

Lock distance

A

Set angle

Lock angle

Toggle relative angle to last segment

X

Set X coordinate

Lock X coordinate

Toggle relative X to last vertex

Y

Set Y coordinate

Lock Y coordinate

Toggle relative Y to last vertex

C

Toggle construction mode

P

Toggle perpendicular and parallel modes

14.5.6.4. Absolute reference digitizing

When drawing a new geometry from scratch, it is very useful to have the possibility to start digitizing vertexes at given coordinates.

For example, to add a new feature to a polygonal layer, click the capturePolygon button. You can choose the X and Y coordinates where you want to start editing the feature, then:

  • Click the x text box (or use the X keyboard shortcut).

  • Type the X coordinate value you want and press Enter or click the locked button to their right to lock the mouse to the X axis on the map canvas.

  • Click the y text box (or use the Y keyboard shortcut).

  • Type the Y coordinate value you want and press Enter or click the locked button to their right to lock the mouse to the Y axis on the map canvas.

Two blue dotted lines and a green cross identify the exact coordinates you entered. Start digitizing by clicking on the map canvas; the mouse position is locked at the green cross.

../../../_images/advanced_digitizing_coordinates.png

Fig. 14.96 Start drawing at given coordinates

You can continue digitizing by free hand, adding a new pair of coordinates, or you can type the segment’s length (distance) and angle.

If you want to draw a segment of a given length, click the d (distance) text box (keyboard shortcut D), type the distance value (in map units) and press Enter or click the locked button on the right to lock the mouse in the map canvas to the length of the segment. In the map canvas, the clicked point is surrounded by a circle whose radius is the value entered in the distance text box.

../../../_images/advanced_digitizing_distance.png

Fig. 14.97 Fixed length segment

Finally, you can also choose the angle of the segment. As described before , click the a (angle) text box (keyboard shortcut A), type the angle value (in degrees), and press Enter or click the locked buttons on the right to lock it. In this way the segment will follow the desired angle:

../../../_images/advanced_digitizing_angle.png

Fig. 14.98 Fixed angle segment

14.5.6.5. Relative reference digitizing

Instead of using absolute values of angles or coordinates, you can also use values relative to the last digitized vertex or segment.

For angles, you can click the delta button on the left of the a text box (or press Shift+A) to toggle relative angles to the previous segment. With that option on, angles are measured between the last segment and the mouse pointer.

For coordinates, click the delta buttons to the left of the x or y text boxes (or press Shift+X or Shift+Y) to toggle relative coordinates to the previous vertex. With these options on, coordinates measurement will consider the last vertex to be the X and Y axes origin.

14.5.6.6. Continuous lock

Both in absolute or relative reference digitizing, angle, distance, X and Y constraints can be locked continuously by clicking the lockedRepeat Continuous lock buttons. Using continuous lock allows you to digitize several points or vertexes using the same constraints.

14.5.6.7. Parallel and perpendicular lines

All the tools described above can be combined with the cadPerpendicular Perpendicular and cadParallel Parallel tools. These two tools allow drawing segments perfectly perpendicular or parallel to another segment.

To draw a perpendicular segment, during the editing click the cadPerpendicular Perpendicular icon (keyboard shortcut P) to activate it. Before drawing the perpendicular line, click on the segment of an existing feature that you want to be perpendicular to (the line of the existing feature will be colored in light orange); you should see a blue dotted line where your feature will be snapped:

../../../_images/advanced_digitizing_perpendicular.png

Fig. 14.99 Perpendicular digitizing

To draw a parallel feature, the steps are the same: click on the cadParallel Parallel icon (keyboard shortcut P twice), click on the segment you want to use as reference and start drawing your feature:

../../../_images/advanced_digitizing_parallel.png

Fig. 14.100 Parallel digitizing

These two tools just find the right angle of the perpendicular and parallel angle and lock this parameter during your editing.

14.5.6.8. Construction mode

You can enable and disable construction mode by clicking on the cadConstruction Construction icon or with the C keyboard shortcut. While in construction mode, clicking the map canvas won’t add new vertexes, but will capture the clicks’ positions so that you can use them as reference points to then lock distance, angle or X and Y relative values.

As an example, the construction mode can be used to draw some point at an exact distance from an existing point.

With an existing point in the map canvas and the snapping mode correctly activated, you can easily draw other points at given distances and angles from it. In addition to the cad button, you have to activate also the construction mode by clicking the cadConstruction Construction icon or with the C keyboard shortcut.

Click next to the point from which you want to calculate the distance and click on the d box (D shortcut) type the desired distance and press Enter to lock the mouse position in the map canvas:

../../../_images/advanced_digitizing_distance_point.png

Fig. 14.101 Distance from point

Before adding the new point, press C to exit the construction mode. Now, you can click on the map canvas, and the point will be placed at the distance entered.

You can also use the angle constraint to, for example, create another point at the same distance of the original one, but at a particular angle from the newly added point. Click the cadConstruction Construction icon or with the C keyboard shortcut to enter construction mode. Click the recently added point, and then the other one to set a direction segment. Then, click on the d text box (D shortcut) type the desired distance and press Enter. Click the a text box (A shortcut) type the angle you want and press Enter. The mouse position will be locked both in distance and angle.

../../../_images/advanced_digitizing_distance_angle_point.png

Fig. 14.102 Distance and angle from points

Before adding the new point, press C to exit the construction mode. Now, you can click on the map canvas, and the point will be placed at the distance and angle entered. Repeating the process, several points can be added.

../../../_images/advanced_digitizing_distance_point_final.png

Fig. 14.103 Points at given distance and angle

14.5.7. The Processing in-place layer modifier

The Processing menu provides access to a large set of tools to analyze and create new features based on the properties of the input features or their relations with other features (within the same layer or not). While the common behavior is to create new layers as outputs, some algorithms also allow modifications to the input layer. This is a handy way to automate multiple features modification using advanced and complex operations.

To edit features in-place:

  1. Select the layer to edit in the Layers panel.

  2. Select the concerned features. You can skip this step, in which case the modification will apply to the whole layer.

  3. Press the processSelected Edit Features In-Place button at the top of the Processing toolbox. The list of algorithms is filtered, showing only those compatible with in-place modifications, i.e.:

    • They work at the feature source and not at the layer level.

    • They do not change the layer structure, e.g. adding or removing fields.

    • They do not change the geometry type, e.g. from line to point layer.

    ../../../_images/edit_inplace_algorithms.png

    Fig. 14.104 Processing algorithms: all (left) vs polygon in-place editors (right)

  4. Find the algorithm you’d like to run and double-click it.

    Muista

    If the algorithm does not need any additional user-set parameters (excluding the usual input and output layer parameters), then the algorithm is run immediately without any dialog popup.

    1. If parameters other than the usual input or output layers are needed, the algorithm dialog pops up. Fill in the required information.

    2. Click Modify Selected Features or Modify All Features depending on whether there’s an active selection.

    Changes are applied to the layer and placed in the edit buffer: the layer is indeed toggled to editing mode with unsaved modification as indicated by the editableEdits icon next to the layer name.

  5. As usual, press saveEdits Save layer edits to commit the changes in the layer. You can also press undo Undo to rollback the whole modification.