You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SRTM 1 second arc elevation data and optimal cycling path from the Cathedral of Christ the Saviour to the Pushkin Square in Moscow
# A proof-of-concept code to calculate
# cycling distance between two points in
# central Moscow that incorporates elevation profiles
#
# By Dmitriy Skougarevskiy, 2016-10-30
# Dependencies
#install.packages(c("gdistance", "RColorBrewer"))
library(gdistance)
library(RColorBrewer)
setwd("your/path")
# Use SRTM V3 elevation raster with 1 arc second (~30 metres)
# resolution from http://earthexplorer.usgs.gov/download/8360/SRTM1N55E037V3/GEOTIFF/EE
# (SRTM1N55E037V3, acquired on 11 February 2000)
# Load the raster of Moscow heights
moscow_area <- raster("n55_e037_1arc_v3.tif")
# Crop to the area within the Garden Ring
moscow_centre <- crop(moscow_area, extent(37.5860, 37.6556, 55.7339, 55.7734))
# Clean up
rm(moscow_area)
# Ensure that our crop was correct
# plot(moscow_centre)
# Hill shading
hill_slope <- terrain(moscow_centre, opt = "slope")
aspect <- terrain(moscow_centre, opt = "aspect")
hill <- hillShade(hill_slope, aspect, 40, 270)
# Cycling distance computation between two points
# Builds on Example 1 of vignette("gdistance1")
altDiff <- function(x){x[2] - x[1]}
hd <- transition(moscow_centre, altDiff, 8, symm = F)
slope <- geoCorrection(hd)
adj <- adjacent(moscow_centre, cells=1:ncell(moscow_centre), pairs = T, directions = 8)
speed <- slope
# Tobler's Hiking function
speed[adj] <- 6 * exp(-3.5 * abs(slope[adj] + 0.05))
# Cycling function from P Nourian, F Hoeven, S Rezvani & S Sariylidiz (2015)
# "Easiest paths for walking and cycling: Combining syntactic and geographic
# analyses in studying walking and cycling mobility"
# NB: this function seems to have errors
#speed[adj] <- (85*9.81*sin(abs(slope[adj]))+25)/112
Conductance <- geoCorrection(speed)
# Introduce two coordinates to compute shortest cycling path
## A hypothetical start point (the Cathedral of Christ the Saviour)
start <- c(37.6053, 55.7446)
## A hypothetical end point (Pushkin's square)
finish <- c(37.6063, 55.7651)
start_finish_hiking_path <- shortestPath(Conductance, start, finish, output="SpatialLines")
# Final plot
png(file = "moscow_centre_elevation_path.png", width = 2400, height = 2400, pointsize = 60)
par(mar=c(0,0,0,0))
plot(hill, col = grey(0:100/100), legend = F, main = "")
plot(moscow_centre, col = rev(brewer.pal(11,"RdYlBu")), alpha=0.5, add=TRUE)
lines(start_finish_hiking_path, col="green", lwd = 20)
text(start[1], start[2] - 0.001, "Christ the Saviour", col = "white")
text(finish[1], finish[2] + 0.001, "Pushkin Square", col = "white")
dev.off()