Package: slopes 2.0.0

Robin Lovelace

slopes: Calculate Slopes of Roads, Rivers and Trajectories

Calculates the slope (longitudinal gradient or steepness) of linear geographic features such as roads (for more details, see Ariza-López et al. (2019) <doi:10.1038/s41597-019-0147-x>) and rivers (for more details, see Cohen et al. (2018) <doi:10.1016/j.jhydrol.2018.06.066>). It can use local Digital Elevation Model (DEM) data or download DEM data via the 'ceramic' package. The package also provides functions to add elevation data to linestrings and visualize elevation profiles.

Authors:Robin Lovelace [aut, cre, cph], Rosa Félix [aut], Joey Talbot [aut], Gonçalo Matos [aut], Dan Olner [rev], Andy Teucher [rev]

slopes_2.0.0.tar.gz
slopes_2.0.0.zip(r-4.7)slopes_2.0.0.zip(r-4.6)slopes_2.0.0.zip(r-4.5)
slopes_2.0.0.tgz(r-4.6-any)slopes_2.0.0.tgz(r-4.5-any)
slopes_2.0.0.tar.gz(r-4.7-any)slopes_2.0.0.tar.gz(r-4.6-any)
slopes_2.0.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
slopes/json (API)

# Install 'slopes' in R:
install.packages('slopes', repos = c('https://ropensci.r-universe.dev', 'https://cloud.r-project.org'))

Reviews:rOpenSci Software Review #420

Bug tracker:https://github.com/ropensci/slopes/issues

Pkgdown/docs site:https://docs.ropensci.org

Datasets:

On CRAN:

Conda:

8.65 score 77 stars 55 scripts 141 downloads 23 exports 16 dependencies

Last updated from:a50419a719 (on master). Checks:10 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64OK183
pkgdown docsOK259
source / vignettesOK225
linux-release-x86_64OK190
macos-release-arm64OK117
macos-oldrel-arm64OK138
windows-develOK142
windows-releaseOK124
windows-oldrelOK123
wasm-releaseOK191

Exports:dem_lisbonelevation_addelevation_extractelevation_getplot_dzplot_sloperoute_to_segmentssequential_distslope_breaksslope_colorsslope_distanceslope_distance_meanslope_distance_weightedslope_matricesslope_matrixslope_matrix_meanslope_matrix_to_rasterslope_matrix_weightedslope_rasterslope_vectorslope_xyzslope_xyz_simpleslopes_palette

Dependencies:classclassIntcolorspaceDBIe1071geodistKernSmoothMASSpbapplyproxyRcpps2sfterraunitswk

Get started
Installation | Installation for DEM downloads | Functions | Elevation | Slope calculation | Plotting | Helper functions | Examples | Add elevation to linestrings or points | Calculate slope | Plot elevation profile | Working with segments | By vertex (native segments of the linestring) | By fixed length (using stplanr)

Last update: 2026-06-22
Started: 2020-05-05

Verification of slopes
Introduction | Case studies | Roads in the Netherlands | Comparison of DEM-derived and survey-grade Z values | DEM for eu: | Test it's installed: | Find location of aws cli from powershell (equivalent of which aws on Linux): | Get-Command aws | Select-Object -ExpandProperty Source | C:\Program Files\Amazon\AWSCLIV2\aws.exe | Now aws should work | Download DEM for Brussels 6 km from center | Calculate slopes with the slopes package: | Add elevation to cycle network segments | check the extents of both: | Calculate slopes for each segment | cycle_net_xyz$slope = slope_xyz(cycle_net_xyz, lonlat = TRUE, fun = slope_matrix_mean) | Convert to percentage: | Convert to factor with greater than 5 being "5+" | Drop z dimension | install cran version | Save with tmap | url of the file: | References

Last update: 2026-06-20
Started: 2020-05-06

Benchmarking slopes calculation
Performance

Last update: 2026-06-16
Started: 2021-06-21

An introduction to slopes
Introduction | Calculating slopes | Measures of route hilliness | Segments in a route: Cumulative slope | References

Last update: 2025-05-29
Started: 2021-08-24

Example: gradients of a road network for a given city
Extract the OSM network from geofabrik | Clean the road network | Filter the unconnected segments | Break the segments on vertices | Get slope values for each segment | Result: | Other examples

Last update: 2025-05-29
Started: 2021-06-21

Readme and manuals

Help Manual

Help pageTopics
Cycle route datacyclestreets_route
Read the bundled Lisbon DEM as a SpatRasterdem_lisbon
Extract distance and elevation data from routedistance_z
Add elevation data to routes linestrings or pointselevation_add
Extract elevation values from coordinateselevation_extract
Get elevation data for routeselevation_get
Lisbon road networklisbon_road_network
Lisbon road segmentlisbon_road_segment
Lisbon road segment 3Dlisbon_road_segment_3d
Lisbon road segment XYZlisbon_road_segment_xyz_mapbox
Lisbon route datalisbon_route
Lisbon route 3Dlisbon_route_3d
Lisbon route XYZlisbon_route_xyz_mapbox
Magnolia coordinatesmagnolia_xy
Create slope breaks for color mappingmake_breaks
Assign colors to slope valuesmake_colz
Create color palette for slope visualizationmake_pal
Plot distance-elevation profile with slope coloringplot_dz
Plot elevation profile with slope coloringplot_slope
Split a route into vertex-to-vertex segmentsroute_to_segments
Calculate sequential distances between pointssequential_dist
Extract midpoint and extent from routes in lonlatsf_mid_ext_lonlat
Recommended slope break thresholds (as proportions)slope_breaks
Recommended slope colours (dark green to dark red)slope_colors
Calculate slopes using distance dataslope_distance
Calculate mean slope using distance weightingslope_distance_mean
Calculate distance-weighted slopesslope_distance_weighted
Calculate slopes for multiple coordinate matricesslope_matrices
Calculate slopes from coordinate matrixslope_matrix
Calculate mean slope from coordinate matrixslope_matrix_mean
Convert slope matrix to SpatRasterslope_matrix_to_raster
Calculate weighted slopes from coordinate matrixslope_matrix_weighted
Calculate slopes using raster elevation dataslope_raster
Calculate slopes from vector dataslope_vector
Calculate slopes from XYZ coordinate dataslope_xyz
Extract XYZ coordinates from SpatRaster or matrixslope_xyz_simple
Get color palette for slopes visualizationslopes_palette