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

overline example is broken #272

Closed
mpadge opened this issue Oct 25, 2018 · 4 comments
Closed

overline example is broken #272

mpadge opened this issue Oct 25, 2018 · 4 comments

Comments

@mpadge
Copy link
Member

mpadge commented Oct 25, 2018

> sl <- routes_fast[2:4, ]
> routes_fast$group <- rep(1:3, length.out = nrow(routes_fast))
> rnet_grouped <- overline(routes_fast, attrib = "length", byvars = "group", buff_dist = 1)
Error in `[.data.frame`(x@data, i, j, ..., drop = FALSE) : 
  undefined columns selected

?

@Robinlovelace
Copy link
Member

Thanks for reporting. I think this is likely due to dplyr code under the hood. Any ideas @richardellison (who added the byvars argument) ?

@Robinlovelace
Copy link
Member

Update: inside the function call I get this, the root of the problem I think:

split(sl, sl@data[, byvars])
Error in `[.data.frame`(x@data, i, j, ..., drop = FALSE) : 
  undefined columns selected

@Robinlovelace
Copy link
Member

Update: split() still seems to be working on SpatialLinesDataFrames (I thought that was the issue):

library(sp)
library(stplanr)
s1 = split(routes_fast, f = rep(1:5, length.out = nrow(routes_fast)))
class(s1[[1]])
#> [1] "SpatialLinesDataFrame"
#> attr(,"package")
#> [1] "sp"
s2 = split(routes_fast_sf, f = rep(1:5, length.out = nrow(routes_fast)))
class(s2[[1]])
#> [1] "sf"         "data.frame"

Created on 2018-10-26 by the reprex package (v0.2.1)

@Robinlovelace
Copy link
Member

Thanks for pointing that out - shows the danger of not running examples. I've fixed it for now by removing the byvars argument altogether. Simplifying the function is good in preparation for general overhaul in light of developments in dodger. I'm confident line aggregation is useful and sure there's big gains to be made by refactoring this, especially overline.sf using sf / other. Suggestions welcome!

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