[GIS] How to calculate the distance to the nearest water source

distancegrassqgisraster

I have a polygon hydro layer of my study area and am trying to calculate the distance to nearest water bodies from my site. Since my site are 2km*2km grids I am not sure how to calculate it? Whether to calculate from centroids of the grids or convert the layer to raster and somehow calculate mean distance of raster cells within the grid. Would be a great help if somebody could provide steps 🙂

Best Answer

If you are working with GRASS, then you can use the module v.distance. When you import the 2kmX2km grid into grass, it automatically creates centroids for each grid cell (that's how the vector design in GRASS works). So you would first add a column in the grids table to hold the distance value, then run v.distance to update that column:

(Assuming two GRASS vector maps, 'water' and 'grid')

v.db.addcolumn map=grid column="dist_to_water double"
v.distance from=grid from_type=centroid to=water upload=dist column=dist_to_water

View the results:

v.db.select grid