By David Crowther
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.
However, when we run the Clip tool…
…it is throwing an error stating that the clipping layer has invalid geometry…. likely the self-intersection in the top right of the layer.
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.
Or firstly select the Clip Layer in the map…
and then from the Search panel, type fix and then choose Fix geometries > using the Edit Selected Features sub menu.
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.
If we now run the CLIP tool again, this time the Clip runs with no error message about invalid geometry.
The Roads layer is now clipped against the newly fixed polygon clip layer.
Comments (0 comments)