I am trying to calculate the cost of walking a predefined path. The path can be a line or a number of points along that line. I have a DEM and derived it's slope, which I will use as a friction map. I want to know the cost of getting from point A to point B using the line/points as a path, not the least cost path.
1 Answer
Using GRASS GIS, you could convert the path to a raster, then extract the slope values from all slope pixels along the path raster, and sum them up. So:
# Assuming a line vector named "path" and cost raster named "slope"
v.to.rast input=path output=path type=line use=val value=1
r.mapcalc "path_cost = if (path=1, slope, null())"
# The sum of the pixels will be the total cost based on slope of all pixels "under" the path
r.univar path_cost # Check value of "sum"