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

Issue in documentation #431

Closed
Robinlovelace opened this issue Sep 22, 2020 · 2 comments
Closed

Issue in documentation #431

Robinlovelace opened this issue Sep 22, 2020 · 2 comments

Comments

@Robinlovelace
Copy link
Member

Via email:

I found a small mistake in your reference manual for stplanr: https://cran.r-project.org/web/packages/stplanr/index.html

The argument text of “route_nearest_point” does not match the behaviour of the function.

It says:

  • An sf object with one feature containing a linestring geometry to be split
    

    A point represented by an sf object the will split the route

However, as this is a replacement for st_nearest_feature there is no splitting involved, right?

@MTueting
Copy link

MTueting commented Sep 22, 2020

Reference Manual p. 84:

Description
This function was written as a drop-in replacement for sf::st_nearest_feature(), which only
works with recent versions of GEOS.

Usage
route_nearest_point(r, p, id_out = FALSE)

Arguments
r An sf object with one feature containing a linestring geometry to be split
p A point represented by an sf object the will split the route
id_out Should the index of the matching feature be returned? FALSE by default

The function does indeed work similar to sf::st_nearest_feature (if id_out = TRUE)

library(stplanr)
library(sf)
library(dplyr)

r <- routes_fast_sf[2:6, NULL]
p <- sf::st_sfc(sf::st_point(c(-1.540, 53.826)), crs = sf::st_crs(r))
route_nearest_point(r, p, id_out = TRUE)
r_nearest <- route_nearest_point(r, p)
plot(r$geometry)
plot(p, add = TRUE)
plot(r_nearest, lwd = 5, add = TRUE)

# Similar to st_nearest_feature

st_nearest_feature(p, r)
r_nearest <- r[st_nearest_feature(p, r),]
plot(r$geometry)
plot(p, add = TRUE)
plot(r_nearest, lwd = 5, add = TRUE)

Rplot1

However, the argument section suggests that the function does some sort of splitting, similar to stplanr::route_split()

r_split <- route_split(r_nearest, p)

# Only for visual purposes
r_split <- r_split %>% mutate(n = 1:n())

plot(r$geometry)
plot(p, add = TRUE)
plot(r_split[2], lwd = 5, add = TRUE)

Rplot2

In my opinion the attribute description for r and p should be something like:
Arguments
r An sf object containing linestrings
p A point represented by an sf object for which the nearest linestring will be found
id_out Should the index of the matching feature be returned? FALSE by default

@Robinlovelace
Copy link
Member Author

Heads-up @MTueting I think the issue is fixed now. Please check the code changed in the commit above. Any further issues, please let me know. Many thanks!

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