Points layer is structured as below
Polygons layer also has code as a field
For each point, I want to get maximum possible distance to the edge of the polygons listed with code in the overlap column. Line must not leave the polygon at any point e.g. in the case of complex polygon shapes.
The red arrow is the max distance to the edge
I tried this from the Field Calculator on the points layer: seems to work but gives more distances than overlaps! If there are two overlaps I need two maximum distances.
array_to_string(
array_foreach(
array_distinct(string_to_array("overlaps", ',')),
format_number(
maximum(
distance(
$geometry,
boundary(
geometry(
get_feature('polygons___majorlang_6318baec_9d66_4f7c_ae25_a2b3a2e2ec27', 'code', trim(@element))
)
)
)
),
2
)
),
', '
)
Best Answer
Use the following expression to find the vertex most distant (farthes) from a point inside a polygon - replace
polygon
on line 3 with the name of your polygon layer:The expression checks for each vertex of the blue polygon the distance to the orange point (black dotted line; just for visualization) and returns just the vertex with the largest distance; the yellow circle (buffer) shows that indeed, the red point is the farthes away from the orange one: