O'Reilly logo

Building Mapping Applications with QGIS by Erik Westra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Editing lines and polygons

The last major functionality we will examine is the ability to edit LineString and Polygon features. Just as the CaptureTool allowed the user to click and drag to create new lines and polygons, we will implement EditTool, which lets the user click and drag to move the existing feature's vertices. The following image shows what the user will see when they use this tool to move a vertex:

Editing lines and polygons

Our editing tool will also let the user add new vertices by double-clicking on a line segment, and delete vertices by right-clicking on the same line segment.

Let's define our EditTool class:

class EditTool(QgsMapTool): def __init__(self, mapCanvas, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required