3

I have a layer with Polygon and a layer with Polylines.

I am looking for the list of Polygons crossed by the Polylines.

Just here it's relatively simple: intersection function.

That said, the layout of the line is not perfect, so I would like to exclude polygon for which the line only touches the polygon contour or does not fit more than 1m into the polygon.

  • have you been able to make it work? – ThingumaBob Sep 5 '18 at 10:33
  • unfortunately, the result of the query does not take into account the tolerance. I have the same result as with a simple intersection. On the other hand, I found another solution which consisted in applying beforehand a negative buffer zone of 1m on the polygons – tdeleye Sep 6 '18 at 5:50
2

I'd go for SQL (QGIS natively supports the SpatiaLite 4.3.0 dialect for any layer query) and check for the spatial relation with the negative buffered polygons:

  • QGIS | DB Manager

    • connect to Virtual Layers (double-click) in the left panel (make sure your layers are loaded in the project)
    • open the SQL Window (second icon to the left)

      • in the top panel, run (Execute)

        SELECT a.<id>,
               group_concat(b.<id>) AS its_lines,
               a.geometry 
        FROM <polygon_layer> AS a
        JOIN <line_layer> AS b
          ON ST_Relate(ST_Buffer(a.geometry, -1), b.geometry, 'T********')
        GROUP BY a.id;
        
      • load the produced table as a layer to the project by ticking the Load as new layer checkbox and fill in the fields

The above query will return a table with all polygon <id>s (paste the actual id field name here), their geometries and a concatenated string of line <id>s (same here) that intersect, but not touch, the negative buffered polygons of your layer.

Important:
Since you asked for meters, I put -1 in ST_Buffer. However, the function will treat the passed number in CRS units; here, this implies that you are working with a CRS whose units are in meter! If you are working in LatLon, e.g. EPSG:4326, the parameter in ST_Buffer will be treated as degrees...and thus makes no sense. In that case, a transformation into an appropriate projection is necessary; you can do that with
... ST_Buffer(ST_Transform(a.geometry, <srid_of_metric_CRS>), -1) ...

  • Unfortunately, the result of the query does not take into account the tolerance. I have the same result as with a simple intersection. On the other hand, I found another solution which consisted in applying beforehand a negative buffer zone of 1m on the polygons – tdeleye Sep 6 '18 at 5:50
  • @tdeleye that is exactly what this query does... – ThingumaBob Sep 6 '18 at 5:54
0

I think in your case you can try:

Vector > Research Tools > Select by Location

Alternatively, there is also a QGIS plugin namely Spatial Query

References:

  • But does this solve the problem concerning the tolerance? – Jochen Schwarze Sep 4 '18 at 6:23
  • @Jochen Schwarze, probably not. Thank you for a hint. – Taras Sep 4 '18 at 6:32
  • @Jochen Schwarze, I thought that Geometric predicates in Select by Location can define that tolerance. – Taras Sep 4 '18 at 6:38
  • 1
    to be precise, the parameter 'Precision' defines the tolerance, but that works only for tests for 'interaction', not for 'non-interaction'. Example: polygon and two lines, one <1m within it and one <1m outside it. Predicate 'disjoint' and 'precision' >1m will select none of them. Vice versa, predicate 'intersects' and 'precision' >1m will select both of them. – Jochen Schwarze Sep 4 '18 at 6:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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