1

How do I perform gap analysis with line and polygon layer in QGIS?

I have 2 vector layers. The first vector layer has line features and second layer has polygon features as in the following images.

Figure 1: Vector Layer with Line features

Figure 2: Vector Layer with Polygon features

Overlapping Lines and Polygon features

I am trying to perform a gap analysis that is cutting the lines at segments the polygons do not overlay the lines in QGIS.

Shapefiles of line and polygon layers are accessible from the following link: https://drive.google.com/drive/folders/11GhQODoPby9SCnp9WcydOBJHVS3O1Lsv?usp=sharing

1
  • 1
    What do you mean exactly with a Gap Analysis, you probably do not mean this Gap Analysis, do not you? For me your "Gap Analysis" sound more like a "Difference", where using of the "Multipart to singleparts" is also feasible. Commented Jan 22, 2021 at 6:04

2 Answers 2

2

As your polygon layer has invalid geometries, you have to run first this method of Processing tool (Fix geometries). Both layers (I named Polygons as Polygons_fixed) loaded in QGIS look as follow.

enter image description here

Afterward, you need to run Difference Processing tool with following parameters:

enter image description here

After click in Run, resulting layer looks as follow. I used an opacity of 20 % in Polygons_fixed for corroborating that produced line layer effectively corresponds to lines which do not overlap.

enter image description here

1

A simpel example cutting the lines not intersecting a polygon using QGIS Virtual Layers.

select p.id, st_intersection(l.geometry, p.geometry) as geometry from test_line l inner join test_poly p on st_intersects(l.geometry, p.geometry) 

Input a linestring and three polygons.

enter image description here

New virtual layer with linestring intersecting polygons.

enter image description here

2
  • 1
    I think OP wants the contrary: the part of the lines that do not overlap the polygons. Commented Jan 22, 2021 at 9:21
  • Yes. I am looking into the method to find lines which do not overlap. Commented Jan 22, 2021 at 10:44

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.