# Calculate cost of predefined path

Geographic Information Systems Asked by Steffan Clent Davies on August 4, 2020

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.

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"


Answered by Micha on August 4, 2020

## Related Questions

### r.watershed stream/rivers pixel size

0  Asked on March 27, 2021

### The position and size of my Tile Map is incorrect when it is displayed in React-Leaflet

1  Asked on March 27, 2021 by satsuki

### Can I select a subset of pins in Google Earth and export the attached data to a csv file?

1  Asked on March 27, 2021

### How to reduce the dbf size in shapefile in QGIS?

0  Asked on March 27, 2021 by blue_cat

### Adjust pop up container in Leaflet

1  Asked on March 26, 2021 by mrsalamikuchen

### AttributeError: ‘NoneType’ object has no attribute ‘symbolLayer’

0  Asked on March 26, 2021

### Polygon layer became point layer when re-opening the project

0  Asked on March 26, 2021 by tomas-hughes-hallett

### Writing script to convert coordinates in .txt file into polygons using ArcPy

0  Asked on March 26, 2021 by branddev

### Converting XY coordinate points to Lat Lon

1  Asked on March 26, 2021 by konan-pruiksma

### Change Projection of a Web Mercator PCS to rotate it around center

0  Asked on March 26, 2021 by thedrifter

### Spatial join and sum aggregation of two polygon GeoDataFrames in GeoPandas

1  Asked on March 26, 2021

### Taking line substring from pgr_withpoints output

0  Asked on March 26, 2021 by kerry

### No option for R scripts in QGIS

0  Asked on March 26, 2021

### Receiving two different values for same date for Landsat B8 using Google Earth Engine

1  Asked on March 26, 2021 by xdsccc

### QGIS to ArcMap file delivery via geopackage

4  Asked on March 26, 2021

### Creating parallel lines in Geographic Coordinate System using ArcPy?

0  Asked on March 26, 2021 by sdmarth

### Merging layers with same name in PyQGIS

3  Asked on March 26, 2021 by raosaeedali

### Get shortest/fastest path between two points from SpatialLines(DataFrame)

2  Asked on March 26, 2021 by squeezie

### QGIS 3.14 GDAL ERROR

0  Asked on March 26, 2021 by brbara-duarte

### Publish geoprocessing service from Python Toolbox to ArcServer 10.7 from ArcMap

1  Asked on March 26, 2021 by freshop