knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(slopes)

Introduction

Although there are several ways to name "slope", such as "steepness", "hilliness", "inclination", "aspect", "gradient", "declivity", the referred slopes in this package can be defined as the "longitudinal gradient" of linear geographic entities, as defined in the context of rivers by[@cohen_global_2018].

The package was initially developed to research road slopes to support evidence-based sustainable transport policies. Accounting for gradient when planning for new cycling infrastructure and road space reallocation for walking and cycling can improve outcomes, for example by helping to identify routes that avoid steep hills. The package can be used to calculate and visualise slopes of rivers and trajectories representing movement on roads of the type published as open data by @ariza-lopez_dataset_2019.

Data on slopes are useful in many fields of research, including hydrology, natural hazards (including flooding and landslide risk management), recreational and competitive sports such as cycling, hiking, and skiing. Slopes are also also important in some branches of transport and emissions modelling and ecology. A growing number of people working with geospatial data require accurate estimates of gradient, including:

There likely other domains where slopes could be useful, such as agriculture, geology, and civil engineering.

An example of the demand for data provided by the package is a map showing gradients across Sao Paulo (Brazil, see image below) that has received more than 300 'likes' on Twitter and generated conversations: https://twitter.com/DanielGuth/status/1347270685161304069

{ width=50% }

Calculating slopes

The most common slope calculation method is defined by the vertical difference of the final and start point or line height (z1 and z0) divided by the horizontal length that separates them.

$$ s = \Delta z/l $$

Depending on the purpose of application, it might me relevant to understand how hilliness is estimated.

Traffic sign{ width=10% }

Measures of route hilliness

There are many ways to measure hilliness, mean distance weighted hilliness being perhaps the most common. These measures, and their implementation (or current lack thereof) in the package is summarised below.

$$ H(x) = 1 - distance.weighted.harmonic.mean(1-x) $$

Segments in a route: Cumulative slope

The length of a segment in a route is also a relevant factor to have in consideration. If it is ok to bike through a segment of 8% with xx length, it is not so ok to bike in four segments in a row like that one (8% for 4xx length), as illustrated bellow.

knitr::include_graphics("SLOPES-commulative-slope-1.png")

This is accounted for in slope calculation methods that take the distance-weighted mean of slopes.

x = c(0, 2, 3, 4, 5, 9)
y = c(0, 0, 0, 0, 0, 9)
z = c(1, 2, 2, 4, 3, 1) / 10
m = cbind(x, y, z)
d = sequential_dist(m = m, lonlat = FALSE)

slopes::slope_distance_weighted(d = d, elevations = z)
slopes::slope_distance_mean(d = d, elevations = z)

The slope estimate that results from the distance-weighted mean is lower than the simple mean. This is common: steep slopes tend to be short!

A graphical representation of the scenario demonstrated above is shown in Figure \@ref(fig:weighted), that shows the relatively long and flat final segment reduces the slope by half.

plot(x, z, ylim = c(-0.5, 0.5), type = "l")
(gxy = slope_matrix(m, lonlat = FALSE))
abline(h = 0, lty = 2)
points(x[-length(x)], gxy, col = "blue")
title("Distance elevation profile",
  sub = "Points show calculated gradients of subsequent lines")

References



ITSLeeds/slopes documentation built on Oct. 13, 2024, 3:54 a.m.