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

Problem with walk, bike, tobler cost and dz calculation #219

Closed
xtimbeau opened this issue Oct 23, 2023 · 1 comment
Closed

Problem with walk, bike, tobler cost and dz calculation #219

xtimbeau opened this issue Oct 23, 2023 · 1 comment

Comments

@xtimbeau
Copy link

Hi, working with dodgr on walk and bike profile I came upon a slightly annoying issue.
Using standard profile, I get very high travel times, implying very slow speeds. Looking for the source of the problem, I think there is something wrong in the dz calculation.
From a silicate network, dz is calculated in sc_edge_dist as the difference between altitude of starting point and ending point.
However, dz is then used in tobler cost function (using standard parameters, https://en.wikipedia.org/wiki/Tobler%27s_hiking_function) as such. But Tobler cost function (given those parameters) must rely on the slope, not on the altitude differential. So it would be preferable to caculate dz as a slope, ie. "dz" = (.vx1_z - .vx0_z)/d.
I guess that using this formula would solve the issue?

sc_edge_dist <- function (graph) {

    # no visible binding notes:
    .vx0_z <- .vx1_z <- NULL

    xy0 <- as.data.frame (graph [, c (".vx0_x", ".vx0_y")])
    xy1 <- as.data.frame (graph [, c (".vx1_x", ".vx1_y")])
    graph$d <- geodist::geodist (xy0, xy1, paired = TRUE, measure = "geodesic")
    if (".vx0_z" %in% names (graph) && ".vx1_z" %in% names (graph)) {
        graph <- dplyr::mutate (graph, "dz" = .vx1_z - .vx0_z) %>%
            dplyr::select (-c (.vx0_z, .vx1_z))
    }
    return (graph)
}

@mpadge mpadge closed this as completed in f8c9f33 Oct 24, 2023
@mpadge
Copy link
Member

mpadge commented Oct 24, 2023

You were right @xtimbeau , thanks so much for uncovering that bug, which the commit above fixes. Now it should work as expected.

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

No branches or pull requests

2 participants