-
Notifications
You must be signed in to change notification settings - Fork 6
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
Documents #38
Conversation
It threw an error related with
|
Looking great 🎉 I agree about renaming the example to Regarding GitHub Actions this might fix it but not sure, hope so! #39 |
I think it is ready for your review. In particular the examples - which I had a different story line. We should clarify the
|
@@ -47,6 +47,7 @@ Suggests: | |||
osmextract, | |||
stplanr, | |||
dplyr, | |||
rgdal | |||
rgdal, | |||
tmap |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍 👍
👍 |
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.cyclestreets_route
can be used for this example.lisbon_route_segments
shouln't be renamed tolisbon_route_netw
, because the singular/plural sometimes is confusing.