Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documents #38

Merged
merged 8 commits into from
Aug 24, 2021
Merged

Documents #38

merged 8 commits into from
Aug 24, 2021

Conversation

temospena
Copy link
Collaborator

I reorganized the README + Get Started + Intro to slopes (needed to move this one out of get started).

I am not happy with the Examples section in Get Started (slopes.Rmd and also some in README.Rmd), in particular with the slopes_ functions.

  • It would be cool to ad an example with a GPS data - see line 208 of README - maybe the Leeds cyclestreets_route can be used for this example.
  • Not sure if lisbon_route_segments shouln't be renamed to lisbon_route_netw, because the singular/plural sometimes is confusing.

@temospena
Copy link
Collaborator Author

temospena commented Aug 24, 2021

It threw an error related with slopes.Rmd vignette (Get Started)

 Error: processing vignette 'slopes.Rmd' failed with diagnostics:
  there is no package called 'tmap'
  --- failed re-building 'slopes.Rmd'
  
  --- re-building 'verification.Rmd' using rmarkdown
  --- finished re-building 'verification.Rmd'
  
  SUMMARY: processing the following file failed:
    'slopes.Rmd'
  
  Error: Vignette re-building failed.
  Execution halted

@Robinlovelace
Copy link
Member

Looking great 🎉 I agree about renaming the example to lisbon_route_network and agree re GPS data, we could generate a route.

Regarding GitHub Actions this might fix it but not sure, hope so! #39

@temospena temospena marked this pull request as ready for review August 24, 2021 13:25
@temospena
Copy link
Collaborator Author

temospena commented Aug 24, 2021

I think it is ready for your review. In particular the examples - which I had a different story line.

We should clarify the slopes_ functions:

  • why they need a XY+ separated elevation info, and don't work with XYZ ready to use data.

@@ -47,6 +47,7 @@ Suggests:
osmextract,
stplanr,
dplyr,
rgdal
rgdal,
tmap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A very handy package for the vignette 👍 for using it. I was being overly cautious before but truth is adding as Suggests does not affect 'installability'.

@@ -9,7 +9,7 @@
#' @examples
#' names(dem_lisbon_raster)
#' raster::plot(dem_lisbon_raster)
#' plot(lisbon_road_segments["Avg_Slope"], add = TRUE)
#' plot(lisbon_road_network["Avg_Slope"], add = TRUE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big thumbs up, way better.

@@ -1,11 +1,10 @@
---
title: "An introduction to the slopes package"
title: "Get started"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 this is about getting started quick and will be most useful.

remotes::install_github("itsleeds/slopes")
```

#### Installation for DEM downloads
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


To help research slopes using open source software for reproducibility, we have developed the slopes package.
After you have installed it, load it as follows:
- `plot_dz()` Plot a digital elevation profile based on xyz data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should delete this now as it's no longer exported:

slopes::plot_dz
#> Error: 'plot_dz' is not an exported object from 'namespace:slopes'
slopes:::plot_dz
#> function(
#>   d,
#>   z,
#>   fill = TRUE,
#>   horiz = FALSE,
#>   pal = colorspace::diverging_hcl,
#>   ...,
#>   legend_position = "top",
#>   col = "black",
#>   cex = 0.9,
#>   bg = grDevices::rgb(1, 1, 1, 0.8),
#>   title = "Slope colors (percentage gradient)",
#>   brks = NULL,
#>   seq_brks = NULL,
#>   ncol = 4
#>   ) {
#>   graphics::plot(d, z, type = "l", col = "brown", lwd = 2)
#>   if (fill) {
#>     b = make_breaks(brks)
#>     pal = make_pal(pal, b)
#>     g = slope_vector(x = d, elevations = z)
#>     colz = make_colz(g, b, pal)
#>     lapply(seq(d)[-(length(d))], function(i) {
#>       graphics::polygon(
#>         x = c(d[i:(i + 1)], d[(i + 1):i]),
#>         y = c(z[i], z[i + 1], 0, 0),
#>         col = colz[i],
#>         border = NA
#>       )
#>     })
#>     graphics::lines(d, z, col = col, lwd = 2)
#>     if(is.null(seq_brks)) seq_brks = seq(from = 3, to = length(b) - 2)
#>     s = c(seq_brks[-(length(seq_brks) / 2) -1], max(seq_brks) + 1)
#>     graphics::legend(x = legend_position, legend = b[s] * 100, fill = pal[s],
#>                      ..., bg = bg, title = title, horiz = horiz,
#>                      ncol = ncol, cex = cex)
#>   }
#> }
#> <bytecode: 0x55a8fefe6f68>
#> <environment: namespace:slopes>

Created on 2021-08-24 by the reprex package (v2.0.1)

The result shows a 7.8% gradient *on average*.
As you can see, the retrieved result from elevation information available in mapbox and in this Digital Elevation Model, is quite similar. (See more about these differences in [Verification of slopes](https://itsleeds.github.io/slopes/articles/verification.html).)

### Route with xyz coordinates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect.

If your linestring object already has X, Y and Z coordinates (e.g. from a GPS device), you can use the `slope_` functions directly.

```{r eval=FALSE, include=FALSE}
#not to use like this... it would ge good to have a gps example to demonstrate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Confident we could find a GPS dataset, although this is much better than what was there before.

points(x[-length(x)], gxy, col = "blue")
title("Distance elevation profile",
sub = "Points show calculated gradients of subsequent lines")
In any case, to use the `slopes` package you need **elevation points**, either as a vector, a matrix or as a digital elevation model (DEM) encoded as a raster dataset.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True that, great summary!


- Inverted harmonic mean. If we use the following formula we will get an index that (like the arithmetic mean) makes use of the full dataset, but that is weighted towards the higher gradient segments. Whether this index, the formula of which is shown below, is helpful, remains to be tested. Not yet implemented.
Imagine that we want to go from East hilly area of the map (Santa Catarina) to the West hilly area of the map (Castelo de São Jorge):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be slightly better as:

Imagine that we want to go from the hilly area in the East (Santa Catarina) to the area in the West of the map (Castelo de São Jorge):




## See more in vignettes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 👍 👍

@Robinlovelace Robinlovelace merged commit 26d842b into master Aug 24, 2021
@Robinlovelace Robinlovelace deleted the documents branch August 24, 2021 14:29
@Robinlovelace Robinlovelace mentioned this pull request Aug 27, 2021
51 tasks
@temospena
Copy link
Collaborator Author

d903043

@Robinlovelace
Copy link
Member

👍

@temospena temospena mentioned this pull request Sep 15, 2021
31 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants