Skip to content

Instantly share code, notes, and snippets.

Last active Jan 23, 2019
What would you like to do?
# Import elevation data
r.import --overwrite input=C:\useruser\karisoke\elevation.tif output=elevation

# Import start and end points and convert to raster
v.import --overwrite input=C:\useruser\karisoke\community\least_cost\start1.shp layer=start1 output=start1
v.import --overwrite input=C:\useruser\karisoke\community\least_cost\end1.shp layer=end1 output=end1 --overwrite input=start1@PERMANENT output=start1 use=attr attribute_column=x --overwrite input=end1@PERMANENT output=end use=attr attribute_column=x

# Set analysis area
g.region raster=elevation@PERMANENT

# calculate elevation metrics
r.slope.aspect --overwrite elevation=elevation@PERMANENT slope=slope

# Calculate cost surface
r.cost --overwrite input=slope@PERMANENT output=cost nearest=nearest start_points=start1@PERMANENT stop_points=end1@PERMANENT

# Calculate shortest cost distance
r.drain --overwrite input=cost@PERMANENT output=drain drain=drainv start_points=start1@PERMANENT,end1@PERMANENT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment