I have a raster image (green colour in image). I would like to find the point in this raster that is the farthest from the edge i.e. that point from which the largest number of uninterrupted cells in a given direction to the edge?
-
Do you want to find the green pixel that has the longest minimal path that is only on green pixels? Or on any coloured pixels? That might be the green pixel nearest the centre. What about that green island in the middle? The distance on only-green cells from there is infinite if you can't go on the black pixels...– SpacedmanCommented Apr 30, 2019 at 14:14
-
I don't want to include the island as the black surrounding it are road/rivers. I want to find the green pixel that has the longest minimal path that is only on green pixels.– DunutsCommented Apr 30, 2019 at 23:28
Add a comment
|
1 Answer
QGIS has a tool for called "pole of inaccessibility" which does exactly what you ask for, with one caveat: it works on polygons, not rasters. Fortunately, it should be fairly simple to polygonize this raster.
Instructions to find the "pole of inaccessibility" for the green areas on your raster:
- Polygonize your raster. Quality control the new polygonized layer as follows:
- Make sure the output is separate single polygon features, not multipolygon features. Run
multipart to single part
if necessary. - Make sure the output only contains the parts of the raster you want to analyze. If the black parts of the raster are not defined as "no data" areas, your polygonized layer will have polygons covering these areas as well. Select and delete any polygons that you don't want included in this analysis (the "select by value" tool might be helpful for this step).
- Make sure the output is separate single polygon features, not multipolygon features. Run
- Calculate Pole of inaccessibility of the polygonized layer. This will create a new point layer, with a point in the most inaccessible spot inside each polygon.
- The new layer of inaccessible points has a field called "dist_pole" with the distance from the point to the boundary of the polygon. Select the point with the highest "dist_pole" value. This is the most inaccessible point on your raster.