having a binary raster map of pixels of interest, a road network, and a target point, my goal is to get a raster map with network pixels having as value the number of pixels of interest they allow to reach.

Would you know how i could use GRASS GIS tools to perform this?

The steps i foresee are:

  • rasterize the network using v.to.rast
  • compute pixels of interest distance to the network using r.grow.distance,
  • compute a direction map with r.cost,
  • add the target point to the network with v.net operation=connect,
  • alter network lines directions toward the target,
  • rasterize the network again using v.to.rast use=dir,
  • overwrite the direction map with network direction pixels with r.mapcalc,
  • build a directed graph from direction map,
  • set a value of 1 to nodes that are on pixels of interest,
  • perform a graph traversal toward the target, cumulating nodes values.

By now, i still don't know how to revert lines directions or build the graph.


To revert line direction you can go with v.edit and the flip option.


Using r.watershed -s with cells of interest provided as flow on a distance to network raster map (from r.grow.distance), i obtained the accumulation map answering our issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.