slopes
Package to calculate slopes of roads, rivers and trajectories
Science Score: 39.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 4 DOI reference(s) in README -
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.2%) to scientific vocabulary
Last synced: 10 months ago
·
JSON representation
Repository
Package to calculate slopes of roads, rivers and trajectories
Basic Info
- Host: GitHub
- Owner: ropensci
- License: gpl-3.0
- Language: R
- Default Branch: master
- Homepage: https://docs.ropensci.org/slopes/
- Size: 9.31 MB
Statistics
- Stars: 71
- Watchers: 4
- Forks: 7
- Open Issues: 13
- Releases: 1
Created about 6 years ago
· Last pushed 11 months ago
Metadata Files
Readme
Changelog
Contributing
License
Code of conduct
Codemeta
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# slopes package
[](https://github.com/ropensci/slopes/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/ropensci/slopes)
[](https://github.com/ropensci/software-review/issues/420)
[](https://CRAN.R-project.org/package=slopes)
The **slopes** R package calculates the slope (longitudinal steepness, also known as gradient) of roads, rivers and other linear (simple) features, based on two main inputs:
- [vector](https://r.geocompx.org/spatial-class.html) linestring geometries defined by classes in the [`sf`](https://r-spatial.github.io/sf/) package
- [raster](https://r.geocompx.org/spatial-class.html) objects with pixel values reporting average height, commonly known as digital elevation model (**DEM**) datasets, defined by classes in the [`raster`](https://cran.r-project.org/package=raster) or more recent [`terra`](https://rspatial.org/terra) packages
Data on slopes are useful in many fields of research, including [hydrology](https://en.wikipedia.org/wiki/Stream_gradient), natural hazards (including [flooding](https://response.reliefweb.int/afghanistan) and [landslide risk management](https://assets.publishing.service.gov.uk/media/57a08d0740f0b652dd0016f4/R7815-ADD017_col.pdf)), recreational and competitive sports such as [cycling](https://theclimbingcyclist.com/gradients-and-cycling-an-introduction/), [hiking](https://trailism.com/trail-grades/), and [skiing](https://www.snowplaza.co.uk/blog/16682-skiing-steeps-what-does-gradient-mean-ski-piste/).
Slopes are also also important in some branches of [transport and emissions modelling](https://doi.org/10.1016/j.trpro.2016.05.258) and [ecology](https://doi.org/10.1016/j.ncon.2016.10.001).
See the [`intro-to-slopes` vignette](https://docs.ropensci.org/slopes/articles/intro-to-slopes.html) for details on fields using slope data and the need for this package.
This README covers installation and basic usage. For more information about slopes and how to use the package to calculate them, see the [get started](https://docs.ropensci.org/slopes/articles/slopes.html) and the [introduction to slopes](https://docs.ropensci.org/slopes/articles/intro-to-slopes.html) vignette.
## How it works
The package takes two main types of input data for slope calculation:
- vector geographic objects representing **linear features**, and
- **elevation values** from a DEM representing a continuous terrain surface or which can be downloaded using functionality in the package
The package can be used with two sources of elevation data:
- openly available elevation data via an interface to the [ceramic package](https://github.com/hypertidy/ceramic), enabling estimation of hilliness for routes anywhere worldwide even when local DEM data is lacking. The package takes geographic lines objects and returns elevation data per vertex (providing the output as a 3D point geometry in the `sf` package by default) and per line feature (providing average gradient by default).
- an elevation model, available on your machine.
## Getting started
### Installation
Install the released version of slopes from [CRAN](https://CRAN.R-project.org) with:
```{r, eval=FALSE}
install.packages("slopes")
```
Install the development version from [GitHub](https://github.com/) with:
```{r, eval=FALSE}
# install.packages("remotes")
remotes::install_github("ropensci/slopes")
```
#### Installation for DEM downloads
If you do not already have DEM data and want to make use of the package's ability to download them using the `ceramic` package, install the package with suggested dependencies, as follows:
```{r, eval=FALSE}
install.packages("slopes", dependencies = "Suggests")
# install.packages("remotes")
remotes::install_github("ropensci/slopes", dependencies = "Suggests")
```
Furthermore, you will need to add a MapBox API key to be able to get DEM datasets, by signing up and registering for a key at `https://console.mapbox.com/account/access-tokens/` and then following these steps:
```{r, eval=FALSE}
usethis::edit_r_environ()
# Then add the following line to the file that opens:
```
```
MAPBOX_API_KEY=xxxxx # replace XXX with your api key
```
```{r, eval=FALSE}
# Check that the key is set
Sys.getenv("MAPBOX_API_KEY")
```
## Basic examples
Load the package in the usual way. We will also load the `sf` library:
```{r message=FALSE, warning=FALSE}
library(slopes)
library(sf)
```
The minimum input data requirement for using the package is an `sf` object containing LINESTRING geometries, as illustrated below (requires a MapBox API key):
```{r}
sf_linestring = lisbon_route # import or load a linestring object
```
```{r, eval=FALSE}
# sf_linestring_xyz = elevation_add(sf_linestring) # dem = NULL
# #> Loading required namespace: ceramic
# #> Preparing to download: 12 tiles at zoom = 12 from
# #> https://api.mapbox.com/v4/mapbox.terrain-rgb/
```
```{r, echo=FALSE}
# note: the following should be TRUE
# identical(sf_linestring_xyz, lisbon_route_xyz_mapbox)
sf_linestring_xyz = lisbon_route_xyz_mapbox
```
With the default argument `dem = NULL`, the function downloads the necessary elevation information from Mapbox.
You can also this use a local DEM (`dem = ...`), as shown in the example below:
```{r}
sf_linestring_xyz_local = elevation_add(sf_linestring, dem = dem_lisbon_raster)
```
In both cases you can obtain the average gradient of the linestring with `slope_xyz()` and plot the elevation profile with `plot_slope()` as follows:
```{r elevationprofile}
slope_xyz(sf_linestring_xyz_local)
plot_slope(sf_linestring_xyz_local)
```
_See more functions in [Get started](https://docs.ropensci.org/slopes/articles/slopes.html) vignette._
## See more in vignettes
- [Get started](https://docs.ropensci.org/slopes/articles/slopes.html)
- [An introduction to slopes](https://docs.ropensci.org/slopes/articles/intro-to-slopes.html)
- [Reproducible example: gradients of a road network for a given city](https://docs.ropensci.org/slopes/articles/roadnetworkcycling.html)
- [Verification of slopes](https://docs.ropensci.org/slopes/articles/verification.html)
- [Benchmarking slopes calculation](https://docs.ropensci.org/slopes/articles/benchmark.html)
## Code of Conduct
Please note that this package is released with a [Contributor Code of Conduct](https://ropensci.org/code-of-conduct/).
By contributing to this project, you agree to abide by its terms.
Owner
- Name: rOpenSci
- Login: ropensci
- Kind: organization
- Email: info@ropensci.org
- Location: Berkeley, CA
- Website: https://ropensci.org/
- Twitter: rOpenSci
- Repositories: 307
- Profile: https://github.com/ropensci
CodeMeta (codemeta.json)
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"identifier": "slopes",
"description": "Functions and example data to support research into the slope (also known as longitudinal gradient or steepness) of linear geographic entities such as roads <doi:10.1038/s41597-019-0147-x> and rivers <doi:10.1016/j.jhydrol.2018.06.066>. The package was initially developed to calculate the steepness of street segments but can be used to calculate steepness of any linear feature that can be represented as LINESTRING geometries in the 'sf' class system. The package takes two main types of input data for slope calculation: vector geographic objects representing linear features, and raster geographic objects with elevation values (which can be downloaded using functionality in the package) representing a continuous terrain surface. Where no raster object is provided the package attempts to download elevation data using the 'ceramic' package.",
"name": "slopes: Calculate Slopes of Roads, Rivers and Trajectories",
"codeRepository": "https://github.com/ropensci/slopes/",
"relatedLink": "https://docs.ropensci.org/slopes/",
"issueTracker": "https://github.com/ropensci/slopes/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "1.0.0",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.1.1 (2021-08-10)",
"author": [
{
"@type": "Person",
"givenName": "Robin",
"familyName": "Lovelace",
"email": "rob00x@gmail.com",
"@id": "https://orcid.org/0000-0001-5679-6536"
},
{
"@type": "Person",
"givenName": "Rosa",
"familyName": "Félix",
"email": "rosamfelix@tecnico.ulisboa.pt",
"@id": "https://orcid.org/0000-0002-5642-6006"
},
{
"@type": "Person",
"givenName": "Joey",
"familyName": "Talbot",
"email": "j.d.talbot@leeds.ac.uk",
"@id": "https://orcid.org/0000-0002-6520-4560"
}
],
"maintainer": [
{
"@type": "Person",
"givenName": "Robin",
"familyName": "Lovelace",
"email": "rob00x@gmail.com",
"@id": "https://orcid.org/0000-0001-5679-6536"
}
],
"softwareSuggestions": [
{
"@type": "SoftwareApplication",
"identifier": "terra",
"name": "terra",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=terra"
},
{
"@type": "SoftwareApplication",
"identifier": "knitr",
"name": "knitr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=knitr"
},
{
"@type": "SoftwareApplication",
"identifier": "rmarkdown",
"name": "rmarkdown",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rmarkdown"
},
{
"@type": "SoftwareApplication",
"identifier": "ceramic",
"name": "ceramic",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=ceramic"
},
{
"@type": "SoftwareApplication",
"identifier": "bookdown",
"name": "bookdown",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=bookdown"
},
{
"@type": "SoftwareApplication",
"identifier": "covr",
"name": "covr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=covr"
},
{
"@type": "SoftwareApplication",
"identifier": "testthat",
"name": "testthat",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=testthat"
},
{
"@type": "SoftwareApplication",
"identifier": "osmextract",
"name": "osmextract",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=osmextract"
},
{
"@type": "SoftwareApplication",
"identifier": "stplanr",
"name": "stplanr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=stplanr"
},
{
"@type": "SoftwareApplication",
"identifier": "dplyr",
"name": "dplyr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=dplyr"
},
{
"@type": "SoftwareApplication",
"identifier": "rgdal",
"name": "rgdal",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rgdal"
},
{
"@type": "SoftwareApplication",
"identifier": "tmap",
"name": "tmap",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=tmap"
},
{
"@type": "SoftwareApplication",
"identifier": "leaflet",
"name": "leaflet",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=leaflet"
},
{
"@type": "SoftwareApplication",
"identifier": "bench",
"name": "bench",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=bench"
}
],
"softwareRequirements": {
"1": {
"@type": "SoftwareApplication",
"identifier": "sf",
"name": "sf",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=sf"
},
"2": {
"@type": "SoftwareApplication",
"identifier": "raster",
"name": "raster",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=raster"
},
"3": {
"@type": "SoftwareApplication",
"identifier": "methods",
"name": "methods"
},
"4": {
"@type": "SoftwareApplication",
"identifier": "pbapply",
"name": "pbapply",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=pbapply"
},
"5": {
"@type": "SoftwareApplication",
"identifier": "geodist",
"name": "geodist",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=geodist"
},
"6": {
"@type": "SoftwareApplication",
"identifier": "colorspace",
"name": "colorspace",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=colorspace"
},
"7": {
"@type": "SoftwareApplication",
"identifier": "R",
"name": "R",
"version": ">= 2.10"
},
"SystemRequirements": null
},
"fileSize": "362.052KB"
}
GitHub Events
Total
- Create event: 1
- Release event: 1
- Issues event: 9
- Watch event: 1
- Issue comment event: 22
- Push event: 20
- Pull request review comment event: 1
- Pull request event: 4
- Pull request review event: 3
Last Year
- Create event: 1
- Release event: 1
- Issues event: 9
- Watch event: 1
- Issue comment event: 22
- Push event: 20
- Pull request review comment event: 1
- Pull request event: 4
- Pull request review event: 3
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 48
- Total pull requests: 25
- Average time to close issues: 7 months
- Average time to close pull requests: about 22 hours
- Total issue authors: 8
- Total pull request authors: 5
- Average comments per issue: 3.21
- Average comments per pull request: 1.24
- Merged pull requests: 21
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 9
- Pull requests: 10
- Average time to close issues: about 1 month
- Average time to close pull requests: about 6 hours
- Issue authors: 3
- Pull request authors: 3
- Average comments per issue: 2.0
- Average comments per pull request: 1.8
- Merged pull requests: 7
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- Robinlovelace (30)
- temospena (11)
- maelle (2)
- fulliautomatix-bike (1)
- fiftysevendegreesofrad (1)
- lauren-obrien (1)
- daauerbach (1)
- mpadge (1)
Pull Request Authors
- Robinlovelace (12)
- temospena (5)
- gmatosferreira (5)
- maelle (2)
- annakrystalli (1)
Top Labels
Issue Labels
enhancement (1)
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 187 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 1
- Total maintainers: 1
cran.r-project.org: slopes
Calculate Slopes of Roads, Rivers and Trajectories
- Homepage: https://github.com/ropensci/slopes/
- Documentation: http://cran.r-project.org/web/packages/slopes/slopes.pdf
- License: GPL-3
-
Latest release: 1.0.1
published 12 months ago
Rankings
Dependent packages count: 26.2%
Dependent repos count: 32.2%
Average: 48.3%
Downloads: 86.5%
Maintainers (1)
Last synced:
10 months ago
Dependencies
DESCRIPTION
cran
- R >= 2.10 depends
- colorspace * imports
- geodist * imports
- methods * imports
- pbapply * imports
- raster * imports
- sf * imports
- bench * suggests
- bookdown * suggests
- ceramic * suggests
- covr * suggests
- dplyr * suggests
- knitr * suggests
- leaflet * suggests
- osmextract * suggests
- rgdal * suggests
- rmarkdown * suggests
- stplanr * suggests
- terra * suggests
- testthat * suggests
- tmap * suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/cache v2 composite
- actions/checkout v2 composite
- actions/upload-artifact main composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v1 composite
.github/workflows/pr-commands.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/pr-fetch v1 composite
- r-lib/actions/pr-push v1 composite
- r-lib/actions/setup-r v1 composite
.github/workflows/test-coverage.yaml
actions
- actions/cache v2 composite
- actions/checkout v2 composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v1 composite