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

Bug in line2vertices when line is composed by 2 points #432

Closed
agila5 opened this issue Oct 5, 2020 · 1 comment
Closed

Bug in line2vertices when line is composed by 2 points #432

agila5 opened this issue Oct 5, 2020 · 1 comment

Comments

@agila5
Copy link
Collaborator

agila5 commented Oct 5, 2020

Reprex:

# upgrade packages
remotes::install_github("ropensci/stplanr")
#> Skipping install of 'stplanr' from a github remote, the SHA1 (f3c6c8d2) has not changed since last install.
#>   Use `force = TRUE` to force installation

# packages
library(sf)
#> Linking to GEOS 3.7.1, GDAL 2.2.2, PROJ 4.9.2
library(stplanr)

# fake data
my_fake_linestring <- st_sf(
  data.frame(x = c(1, 2)), 
  geometry = st_sfc(
    st_linestring(rbind(c(0, 0), c(1, 0), c(2, 0))), 
    st_linestring(rbind(c(1, 0), c(1, 1)))
  )
)
plot(my_fake_linestring)

line2vertices(my_fake_linestring)
#> Error in `[.data.frame`(x, coords): undefined columns selected

Created on 2020-10-05 by the reprex package (v0.3.0)

Taken from luukvdmeer/sfnetworks#73. It should be easy to fix and I'm working on a PR

@Robinlovelace
Copy link
Member

Many thanks @agila5, I never came across that edge case, great it now works for straight lines with only 2 points.

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