3

I have the following two layers:

'PARCEL' with polygon geometry corresponding to parcels.

'POINTS' with point geometry corresponding to the segmentation of the 'WAYS' layer at a distance of hectometer.

I need an expression for 'PARCEL' layer for Geometry Generator to draw a line from the midpoint of the nearest facade side to each hectometer POINT.

I have made an approximation with the following function but it is not what I am looking for because I have to generate a new layer with the centroids of 'PARCEL', and I can't capture the center of the side closest to each point either:

shortest_line ( 
collect_geometries ( 
overlay_nearest ( 
'POINT', 
$geometry
 )
 ),
 $geometry
)

enter image description here

What I would like to get: enter image description here

1 Answer 1

4

My polygon layer is named parcel and my point layer is named hectometer.

To create the points (black in my screenshot) on the polygon boundaries closest to the nearest hectometer, combine overlay_nearest with closest_point. Adjust the max distance.

with_variable(name:='nearest', value:=overlay_nearest(layer:='hectometer', expression:=$geometry, limit:=1, max_distance:=300)[0], expression:=closest_point(geometry1:=boundary($geometry), geometry2:=@nearest))

The query will for each polygon find the nearest hectometer point, and retrieve its geometry.

Then combine it with make_line to create the lines:

with_variable(name:='nearest', value:=overlay_nearest(layer:='hectometer', expression:=$geometry, limit:=1, max_distance:=300)[0], expression:=make_line(closest_point(geometry1:=boundary($geometry), geometry2:=@nearest), @nearest))

enter image description here

1
  • 1
    Genial. Works perfectly. Commented Apr 21 at 8:50

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.