I have a two layers. One layer is chairlift data (lines/ways). The other layer is ski resorts (polygons). For the most part, chairlifts are in polygons or cross polygons. When I used "sum line length", I get an accurate number of chairlifts and total length of all chairlifts. There are some chairlifts that are not in polygons. There are many reason but for the most part they are touristy lifts taking people across a waterway or up a mountain (not a ski mountain). I would like to select / remove those chairlifts from my project. I am stumped as to how to do that. Any suggestions?

1 Answer 1


Use QGIS expressions to calclulate length: either 1) of the the overlapping part (intersection) of a linestring with the polygons from a layer called resorts (red labels), or 2) just the total length of those lines completely inside polygons (yellow labels).

Black: total length of each line; red label: length of the part(s) overlapping the blue polygons (expression 1 below); yellow label: length of those lines completely within polygons (expression 2):

enter image description here

1. Length of overlapping parts

To create the red labels from the screenshot, use this expression:

length (
    collect_geometries (
        array_foreach (
            overlay_intersects ('resorts', $geometry),
            intersection ($geometry, @element)

2. Length of lines completely inside polygons

If you just want to calculate the total length of those lifts that are completely within the resorts, use this expression (yellow labels in the screenshot):

if (
  • Sorry but my question is not about calculating the length of a line (as stated, this already works). I am trying to remove all irelavent chairlifts (lines) from the data. In other words, I want to select all lines and polygons which is in a polygon or passes through a polygon. Thanks for the added info though. Sep 18, 2022 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.