-
Notifications
You must be signed in to change notification settings - Fork 66
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
sum_network_routes results differ between sf and sp data #249
Comments
If
looks good to me |
Can you reproduce this plot? The results suggest it's not a big issue, something linked to the creation of the library(stplanr)
from = "Jena Paradies"
to = "JenTower"
(from_coords = geo_code(from))
#> [1] 11.58766 50.92493
(to_coords = geo_code(to))
#> [1] 11.58465 50.92883
u = "https://github.com/Robinlovelace/geocomp-tranport-workshop/raw/master/ways.geojson"
if (!file.exists("ways.geojson")) {
download.file(url = u, destfile = "ways.geojson")
}
ways = sf::read_sf("ways.geojson")
ways_sp = as(ways, "Spatial")
ways_sln = SpatialLinesNetwork(ways_sp)
from_sln = find_network_nodes(ways_sln, from_coords[1], from_coords[2])
to_sln = find_network_nodes(ways_sln, to_coords[1], to_coords[2])
r_local = sum_network_routes(ways_sln, from_sln, to_sln, "length", combinations = F)
ways_sln = SpatialLinesNetwork(ways)
#> Linking to GEOS 3.5.1, GDAL 2.2.2, proj.4 4.9.2
from_sln = find_network_nodes(ways_sln, from_coords[1], from_coords[2])
to_sln = find_network_nodes(ways_sln, to_coords[1], to_coords[2])
r_local_sf = sum_network_routes(ways_sln, from_sln, to_sln, "length", combinations = F)
plot(r_local, lwd = 5)
plot(r_local_sf$geometry, add = TRUE, col = "red") Session infodevtools::session_info()
#> Session info -------------------------------------------------------------
#> setting value
#> version R version 3.4.4 (2018-03-15)
#> system x86_64, linux-gnu
#> ui X11
#> language en_GB:en
#> collate en_GB.UTF-8
#> tz Europe/London
#> date 2018-04-11
#> Packages -----------------------------------------------------------------
#> package * version date source
#> assertthat 0.2.0 2017-04-11 cran (@0.2.0)
#> backports 1.1.2 2017-12-13 CRAN (R 3.4.3)
#> base * 3.4.4 2018-03-16 local
#> bindr 0.1.1 2018-03-13 CRAN (R 3.4.4)
#> bindrcpp * 0.2.2 2018-03-29 CRAN (R 3.4.4)
#> class 7.3-14 2015-08-30 CRAN (R 3.4.0)
#> classInt 0.1-24 2017-04-16 cran (@0.1-24)
#> compiler 3.4.4 2018-03-16 local
#> curl 3.2 2018-03-28 CRAN (R 3.4.4)
#> datasets * 3.4.4 2018-03-16 local
#> DBI 0.8 2018-03-02 cran (@0.8)
#> devtools 1.13.5 2018-02-18 CRAN (R 3.4.4)
#> digest 0.6.15 2018-01-28 CRAN (R 3.4.3)
#> dplyr 0.7.4 2017-09-28 CRAN (R 3.4.3)
#> e1071 1.6-8 2017-02-02 cran (@1.6-8)
#> evaluate 0.10.1 2017-06-24 CRAN (R 3.4.1)
#> foreign 0.8-69 2017-06-21 CRAN (R 3.4.0)
#> formatR 1.5 2017-04-25 CRAN (R 3.4.1)
#> geosphere 1.5-7 2017-11-05 CRAN (R 3.4.2)
#> glue 1.2.0 2017-10-29 CRAN (R 3.4.2)
#> graphics * 3.4.4 2018-03-16 local
#> grDevices * 3.4.4 2018-03-16 local
#> grid 3.4.4 2018-03-16 local
#> htmltools 0.3.6 2017-04-28 cran (@0.3.6)
#> httr 1.3.1 2017-08-20 cran (@1.3.1)
#> igraph 1.2.1 2018-03-10 cran (@1.2.1)
#> jsonlite 1.5 2017-06-01 cran (@1.5)
#> knitr 1.20 2018-02-20 cran (@1.20)
#> lattice 0.20-35 2017-03-25 CRAN (R 3.3.3)
#> lwgeom 0.1-5 2018-03-20 Github (r-spatial/lwgeom@389090c)
#> magrittr 1.5 2014-11-22 CRAN (R 3.3.2)
#> maptools 0.9-2 2017-03-25 cran (@0.9-2)
#> memoise 1.1.0 2017-04-21 CRAN (R 3.4.1)
#> methods * 3.4.4 2018-03-16 local
#> mime 0.5 2016-07-07 CRAN (R 3.3.2)
#> openxlsx 4.0.17 2017-03-23 CRAN (R 3.4.1)
#> pillar 1.2.1 2018-02-27 CRAN (R 3.4.4)
#> pkgconfig 2.0.1 2017-03-21 cran (@2.0.1)
#> R.methodsS3 1.7.1 2016-02-16 cran (@1.7.1)
#> R.oo 1.21.0 2016-11-01 cran (@1.21.0)
#> R.utils 2.6.0 2017-11-05 CRAN (R 3.4.2)
#> R6 2.2.2 2017-06-17 cran (@2.2.2)
#> raster 2.6-7 2017-11-13 CRAN (R 3.4.2)
#> Rcpp 0.12.16 2018-03-13 CRAN (R 3.4.4)
#> rgdal 1.2-18 2018-03-17 CRAN (R 3.4.4)
#> rgeos 0.3-26 2017-10-31 cran (@0.3-26)
#> rlang 0.2.0.9001 2018-04-10 Github (r-lib/rlang@70d2d40)
#> rmarkdown 1.9 2018-03-01 CRAN (R 3.4.4)
#> rprojroot 1.3-2 2018-01-03 CRAN (R 3.4.3)
#> sf * 0.6-2 2018-04-09 Github (r-spatial/sf@b7de234)
#> sp 1.2-7 2018-01-19 cran (@1.2-7)
#> stats * 3.4.4 2018-03-16 local
#> stplanr * 0.2.3.9000 2018-04-10 Github (ropensci/stplanr@4b8abda)
#> stringi 1.1.7 2018-03-12 CRAN (R 3.4.4)
#> stringr 1.3.0 2018-02-19 cran (@1.3.0)
#> tibble 1.4.2 2018-01-22 cran (@1.4.2)
#> tools 3.4.4 2018-03-16 local
#> udunits2 0.13 2016-11-17 cran (@0.13)
#> units 0.5-1 2018-01-08 cran (@0.5-1)
#> utils * 3.4.4 2018-03-16 local
#> withr 2.1.2 2018-04-07 Github (jimhester/withr@79d7b0d)
#> xml2 1.2.0 2018-01-24 CRAN (R 3.4.3)
#> yaml 2.1.18 2018-03-08 CRAN (R 3.4.4) |
Heads-up @cmcaine this may be something you're interested in (discussed Friday last week). |
Thanks :) I'll take a look tomorrow.
…On Tue, 1 May 2018, 10:18 Robin, ***@***.***> wrote:
Heads-up @cmcaine <https://github.com/cmcaine> this may be something
you're interested in (discussed Friday last week).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#249 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFuQeV4KaTe8uES93SaoLjXTlA8K7a1pks5tuChkgaJpZM4TPD8A>
.
|
The problem seems to be related to tidyverse/dplyr#3279 and is happending in lines 555 to 571
The solution would be to go straight from the dataframe of coordiantes to a matrix of cooridnates and then a LINESTRING rather than goin via POINTS |
On a related note, this also fails: SLN_sf2 = SpatialLinesNetwork(routes_fast_sf)
shortpath <- sum_network_routes(SLN_sf2, 1, 2, sumvars = "length") |
Sorry for being slow on this! Definitely has to do with the issue that @mem48 refers to. I will need to fix it. |
Hi @richardellison thanks for confirming. As discussed with @mem48 (who works with me here in Leeds) I've given it a good go but have failed to fix it so far. I suspect it's a regression silently introduced by |
Identified here: https://github.com/Robinlovelace/geocomp-tranport-workshop
If
is replaced by
It produces an incorrect result.
The text was updated successfully, but these errors were encountered: