[GIS] Nearest distance from point to pixel in QGIS

grasspointqgisraster

I have 1) a point layer and 2) a binary raster file (1 and 0). I need to estimate the Euclidean distance from each point to the nearest "1" pixel. I know there is a tool in ArcGIS but I only have access to QGIS/GRASS; in GRASS there is a clear way to estimate this distance but it's between two vectorial layers (using v.distance).

So far, I tried:

1) in QGIS, the Proximity tool, but it doesn't give me the result I want, since it considers only one raster layer

2) in GRASS, r.distance but I get an error ("Raster map is not CELL"), and I am still trying to figure it out, but I'm still not sure which values will it give me since I don't see any option to select a set of pixels ("1", in this case), instead of all the layer

Does anyone know how to do that in QGIS?

Best Answer

With QGIS:

One way is to polygonize your raster and then follow Calculating minimum distance between points and polygons in QGIS?

Another way, may be.

  1. Create a point layer with the processing "Create grid" with the same resolution of your raster
  2. Join the attribut (1 or o) with the plugin "Point sampling tool"
  3. Create a distance matrix Vector -> Analysis Tools -> Distance Matrix (choose "Use only the nearest (k) target points" as 1
Related Question