"QGIS: Displaying labels outside polygons for line features inside using field values"

34 Views Asked by At

How can I display labels for line features in a QGIS line layer, where the label should appear outside a polygon if the line feature is inside the polygon, and otherwise appear as it is? I have activated the "name" field for labeling the line features.enter image description here

difference ( $geometry, buffer ( aggregate( 'polygon', 'collect', buffer ($geometry,15) ), 0 )) i tried the above expression but not working.

1

There are 1 best solutions below

0
Xeppit On
with_variable('polyGeom',overlay_intersects(layer:='Polygon',expression:=@geometry)[0],
with_variable('centroid',centroid(@geometry),
with_variable('offsetY',100,
make_point(x_max(@centroid),y_max(@polyGeom)+@offsetY)
)))

enter image description here