I want to calculate the longest distance between the edge of a polygon and the point that is inside it (or if no point is inside, then the closest point). The polygons are catchments and the travelling distance from the edge of a polygon to a point inside the polygon is wanted. If no points are inside the polygon, the nearest point is used (the neasrest point by means of the nearest line). The longest distance are kept within the polygons and do not cross the polygon border unless there are no points within the polygon.
I find a lot of solutions for the nearest line (such as distance to nearest hub), but not so many on the longest distance. My points are not connected to the polygons (i.e. they are not the centroids), but they have an attribute column in common with ID names of the points. That is, each of the polygons have an attribute with the ID of a point.
I'm still beginner to QGIS, so I'm not that comfortable with post-gis or any kind of coding (but field calculator is okay). Since there are multiple polygons in my layer (100+), I'm searching for a method that does this 'automatically' / without me having to 'measure' each polygon manually.
Does anyone know a good way to solve this?
I've looked at: Distance between centroid and farthest point of polygon which had the focus from a centroid, but otherwise similar.
Also this one is similar and describes the longest distance wish: Finding maximum possible distance of point to polygon boundary using QGIS Expression . Maybe I'm just not good at adapting codes but it didn't work for me. The description was fine. My polygons do not overlap, I just have a lot of them. The figure with gren area describes the case from the link, with the red arrow representing longest distance and yellow the shortest (seen below).
And this: How could you measure the minimum and maximum distance to the outer edge of a polygon in QGIS actually gave me some results, but the max distance was too short in some samples I checked.