• Blog posts

    Bio

    By David Crowther

    QGIS___Fix_Geometries_-_1.PNG

    Question:

    I am running a tool in QGIS and it’s failing as it says the layer has invalid geometry – how can you fix invalid geometry?

    Answer:

    In this example, we have a layer of Road lines, and we are looking to use the Clip tool to select out the roads that intersect a specified polygon boundary layer.

    QGIS___Fix_Geometries_-_2.PNG

    However, when we run the Clip tool…

    QGIS___Fix_Geometries_-_3.PNG

    …it is throwing an error stating that the clipping layer has invalid geometry…. likely the self-intersection in the top right of the layer.

    QGIS___Fix_Geometries_-_4.PNG

    To resolve this issue, we need to use the Fix Geometries tool. This can either be accessed from the Processing menu > Toolbox > and open the Vector Geometry section.

    QGIS___Fix_Geometries_-_5.PNG

    Or firstly select the Clip Layer in the map…

    QGIS___Fix_Geometries_-_6.PNG

    and then from the Search panel, type fix and then choose Fix geometries > using the Edit Selected Features sub menu.

    QGIS___Fix_Geometries_-_7.PNG

    This runs the Fix Geometry tool automatically on the selected feature from the input Clip layer. Once the tool runs the geometry the layer will be fixed. The self-intersection area may look like it remains, but the vertices have been edited to ensure the polygon is now valid.

    QGIS___Fix_Geometries_-_8.PNG

    If we now run the CLIP tool again, this time the Clip runs with no error message about invalid geometry.

    QGIS___Fix_Geometries_-_9.PNG

    The Roads layer is now clipped against the newly fixed polygon clip layer.

    QGIS___Fix_Geometries_-_10.PNG