UrbanAnalyst / dodgr

Distances on Directed Graphs in R
https://urbananalyst.github.io/dodgr/
127 stars 16 forks source link

Error message with dodgr_streetnet #116

Closed Robinlovelace closed 4 years ago

Robinlovelace commented 4 years ago

Not sure what's causing this or if it's even an issue, but it pops up from commented lines in stplanr that I think should be reproducible:

from <- c(-1.5484688, 53.7941618) # geo_code("leeds rail station")
to <-   c(-1.5524571, 53.8038718) # geo_code("university of leeds")
# next 4 lines were used to generate `stplanr::osm_net_example`
pts <- rbind(from, to)
colnames(pts) <- c("X", "Y")
net <- dodgr::dodgr_streetnet(pts = rbind(from, to), expand = 0.1)
#> Error in process_bbox(bbox, pts, expand): Can not unambiguously determine coordinates in graph

Created on 2019-10-03 by the reprex package (v0.3.0)

Robinlovelace commented 4 years ago

Same with the original example:

library(stplanr); (from <- geo_code("gzine leeds"))
#> Registered S3 method overwritten by 'R.oo':
#>   method        from       
#>   throw.default R.methodsS3
#> numeric(0)
(to <- geo_code("pedallers arms leeds"))
#> [1] -1.532771 53.800699
# next 4 lines were used to generate `stplanr::osm_net_example`
pts <- rbind(from, to)
colnames(pts) <- c("X", "Y")
net <- dodgr::dodgr_streetnet(pts = rbind(from, to), expand = 0.1)
#> Error in process_bbox(bbox, pts, expand): Can not unambiguously determine coordinates in graph

Created on 2019-10-03 by the reprex package (v0.3.0)

mpadge commented 4 years ago

That because you've got

dodgr_streetnet(pts = rbind (from, to), ...)

and not

dodgr_streetnet(pts = pts, ...)

The pts have to be named, otherwise it's not clear what is "x" and what is"y". I think that error is okay, right?

Robinlovelace commented 4 years ago

Yes that solves it, thanks, glad I checked!