Comments (2)
Hi,
I first thought this problem was already solved in the dev version of the pkg.
See
remotes::install_github('riatelab/osrm')`
then
library(osrm)
#> Data: (c) OpenStreetMap contributors, ODbL 1.0 - http://www.openstreetmap.org/copyright
#> Routing: OSRM - http://project-osrm.org/
library(sf)
#> Linking to GEOS 3.9.0, GDAL 3.2.2, PROJ 7.2.1; sf_use_s2() is TRUE
point_1 <- c(25086.15, 194501.7)
point_2 <- c(25032.33, 195725.5)
point_3 <- c(24140.32, 193718.8)
point_4 <- c(24217, 194746)
point_5 <- c(24445.09, 195494.1)
point_6 <- c(24368.93, 194250.5)
point_7 <- c(25521.03, 195911.1)
point_8 <- c(25830.59, 195202.3)
point_9 <- c(25235.08, 194137.3)
# Create data frame
point_df <- do.call(rbind.data.frame,
lapply(paste("point", 1:9, sep = "_"), get))
names(point_df) <- c("X", "Y")
# Create sf object
point_sf <- point_df |>
st_as_sf(coords = c("X", "Y"), crs = st_crs(31370))
# Calculate trip
mytrip_car <- osrmTrip(point_sf)
mytrip_foot <- osrmTrip(point_sf, osrm.profile = "foot")
(mytrip_car[[1]]$trip)
#> Simple feature collection with 9 features and 4 fields
#> Geometry type: LINESTRING
#> Dimension: XY
#> Bounding box: xmin: 23624.07 ymin: 193204.7 xmax: 25996.78 ymax: 195831.9
#> Projected CRS: Belge 1972 / Belgian Lambert 72
#> start end duration distance geometry
#> 1 1 3 6.970000 1.5851 LINESTRING (25159.03 194109...
#> 2 3 6 10.055000 2.6630 LINESTRING (25159.03 194109...
#> 3 6 4 6.096667 1.3394 LINESTRING (24374.11 193425...
#> 4 4 5 1.160000 0.4828 LINESTRING (23958.38 194241...
#> 5 5 7 3.550000 1.3431 LINESTRING (24511.62 195110...
#> 6 7 2 1.270000 0.4323 LINESTRING (24133.11 194961...
#> 7 2 8 1.161667 0.7748 LINESTRING (25381.3 195646....
#> 8 8 9 8.516667 3.1316 LINESTRING (25381.3 195646....
#> 9 9 1 0.000000 0.0000 LINESTRING (25309.59 195831...
(mytrip_foot[[1]]$trip)
#> Simple feature collection with 9 features and 4 fields
#> Geometry type: LINESTRING
#> Dimension: XY
#> Bounding box: xmin: 23624.07 ymin: 193204.7 xmax: 25996.78 ymax: 195831.9
#> Projected CRS: Belge 1972 / Belgian Lambert 72
#> start end duration distance geometry
#> 1 1 3 21.13833 1.5851 LINESTRING (25159.03 194109...
#> 2 3 6 35.50833 2.6630 LINESTRING (25159.03 194109...
#> 3 6 4 17.85667 1.3394 LINESTRING (24374.11 193425...
#> 4 4 5 6.43500 0.4828 LINESTRING (23958.38 194241...
#> 5 5 2 17.45833 1.3092 LINESTRING (24511.62 195110...
#> 6 2 7 5.76500 0.4323 LINESTRING (24133.11 194961...
#> 7 7 8 10.78167 0.8087 LINESTRING (25446.87 195476...
#> 8 8 9 41.79167 3.1316 LINESTRING (25381.3 195646....
#> 9 9 1 0.00000 0.0000 LINESTRING (25381.3 195646....
Created on 2023-03-23 with reprex v2.0.2
But inspecting more in details actual road lengths, I see there is still a problem, geometries do not match trip segments. There is a kind of offset. I'll look into it asap. Thank you for the bug report.
trip <- mytrip_car[[1]]$trip
trip$length <- st_length(trip)
(trip)
#> Simple feature collection with 9 features and 5 fields
#> Geometry type: LINESTRING
#> Dimension: XY
#> Bounding box: xmin: 23624.07 ymin: 193204.7 xmax: 25996.78 ymax: 195831.9
#> Projected CRS: Belge 1972 / Belgian Lambert 72
#> start end duration distance geometry length
#> 1 1 3 6.970000 1.5851 LINESTRING (25159.03 194109... 0.0000 [m]
#> 2 3 6 10.055000 2.6630 LINESTRING (25159.03 194109... 1224.1767 [m]
#> 3 6 4 6.096667 1.3394 LINESTRING (24374.11 193425... 2692.4443 [m]
#> 4 4 5 1.160000 0.4828 LINESTRING (23958.38 194241... 1250.3470 [m]
#> 5 5 7 3.550000 1.3431 LINESTRING (24511.62 195110... 407.1056 [m]
#> 6 7 2 1.270000 0.4323 LINESTRING (24133.11 194961... 1593.2942 [m]
#> 7 2 8 1.161667 0.7748 LINESTRING (25381.3 195646.... 466.3010 [m]
#> 8 8 9 8.516667 3.1316 LINESTRING (25381.3 195646.... 199.2373 [m]
#> 9 9 1 0.000000 0.0000 LINESTRING (25309.59 195831... 3905.0552 [m]
Created on 2023-03-23 with reprex v2.0.2
from osrm.
Ok, thank you for your fast reply.
I installed the package from CRAN, not the dev version.
Kind regards,
Ward
from osrm.
Related Issues (20)
- Improve error handling `osrmIsochrone()`: character vector of location HOT 1
- Improve error handling `osrmIsochrone()`: handle empty isochrones
- Improve documentation `osrmIsochrone()`: `breaks` argument
- Define "isometric" and "isodistance"
- Speed parameter HOT 3
- Stop osrm "connecting" to the network via certain types of roads HOT 6
- Problem with input data and osrmTrip() HOT 3
- curl::curl_fetch_memory(utils::URLencode(url) => connection was reset HOT 4
- osrmIsochrone(): 'loc' is too far from the OSRM network but loc is not too far... HOT 9
- pairwise distance matrix from OSRM? HOT 2
- Using custom driving profiles HOT 2
- Problem with self-hosted server connection HOT 11
- Curl Header Overflow for Large Distance Matrices HOT 4
- fix pkg level documentation
- Duration of trip in osrmRoute and time of the day/traffic HOT 1
- Error using `osrmTable` with local server: long vectors not supported yet HOT 1
- Is snaping coordinates to the street network possible when mapping isochrones? HOT 4
- Not working "exclude" option HOT 2
- Retry functionality? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from osrm.