riatelab / osrm Goto Github PK
View Code? Open in Web Editor NEWInterface between R and the OpenStreetMap-based routing service OSRM
Home Page: https://doi.org/10.21105/joss.04574
License: GNU General Public License v3.0
Interface between R and the OpenStreetMap-based routing service OSRM
Home Page: https://doi.org/10.21105/joss.04574
License: GNU General Public License v3.0
Hi,
I am trying to create some isochrones with the package, but the resulting map always includes more than 1 polygons for a single point. Is there a reason why multiple polygons rather than just one are created?
The code I am using looks similar to the package sample:
iso <- osrmIsochrone(loc = c(36.8032934, -1.2567891), breaks = seq(from = 0, to = 10, by = 10), res = 100)
I'll admit I could be doing something wrong and not realize it, but if so, I am having trouble seeing my mistake.
I am having the same issue with the osrmTable and osrmTrip functions, but I have no problem with osrmRoute. For example, I can run this with no issues:
route <- osrmRoute(src = center[1, c("cbsa", "Longitude","Latitude")],
dst = center[2, c("cbsa", "Longitude","Latitude")])
but when I run
distCom <- osrmTable(loc = center[1:5,c("cbsa","Longitude","Latitude")])
I get
osrmTable function returns an error:
Error: Not enough input coordinates given; minimum number of coordinates is 2.
and I get the exact same error with osrmTrip. This doesn't appear to be related to my data since the demo code in the documentation has this same problem:
data("com")
# Travel path between points
route <- osrmRoute(src = com[1, c("comm_id", "lon","lat")],
dst = com[15, c("comm_id", "lon","lat")])
works just fine but I get the same error when I run
data("com")
# Travel time matrix
distCom <- osrmTable(loc = com[1:50, c("comm_id","lon","lat")])
Hi,
when i'm using osrmTable I have this error :
"osrmTable function returns an error:
Error in function (type, msg, asError = TRUE) : Failed to connect to router.project-osrm.org port 80: Timed out"
Could you help me or explain why ?
Furthermore, I would know if it is still possible to have a road distance matrix between points ? (as the osrmTableOD did)
Thanks
Hi, thanks for the great package!
I'm curious if you know if it is possible to get the route object back with an associated time at each point from 'osrm'. Something like this:
library(osrm)
df <- osrmViarouteGeom(17.743773, 59.740056,17.757533, 59.739084)
df$time <- osrmTable(a, id = NULL, x = "lon", y = "lat")[1,]
df
Of course the above code works but it seems like the times should already be available from the route calculation and that the calculation of the times is somehow repeating what was already done?
I am assuming some other package change has caused the problem I am running into. The vignette for osrmIsochrone was working for me previously. But running the script now throws up an error on the line executing:
osm <- getTiles(spdf = iso, crop = TRUE, type = "osmtransport")
The function results in:
Error in { : task 2 failed - "arg 'X2' has dims=256, 256, 4; but need dims=X, 256, 3"
I can step through the code and create the isochrones, but the underlying tiles are the issue. I can create other maps with the cartography package. So I suspect there is something with the spdf created with:
iso <- osrmIsochrone(loc = src[6,], breaks = seq(from = 0,to = 30, by = 5))
Thanks
hi, similar topic may be discussed before.
To be able to use osrm.profile = "walk"
, I rebuilt the osrm instance using foot.lua
. I did this after I finished building the default car.lua
instance, which worked fine.
However, when I tried to build the instance using foot.lua
in a totally new environment, I got an error
[error] Input file "/data/sweden-latest.osrm.ebg" not found!
I noticed this .ebg
file was created in the previous step if using car.lua
, but not foot.lua
.
So I used car.lua
first and then foot.lua
later. It looked like the instance was built okay, and I can set osrm.profile = "walk"
in options
. But the results of osrmIsochrone
was not reassuring. I gave two extreme time intervals to compare.
iso <- osrmIsochrone(loc,
breaks = seq(from = 0, to = 120, by = 60),
res = 400, returnclass = "sf")
and the results, according to my eyes, were very much similar, if not identical.
I guess .ebg
file is where the problem is. Could anybody give some suggestions?
Thanks a lot.
Hello,
When running osrmTrip, I am receiving two errors that I am having difficulty interpreting.
The first is:
"OSRM returned an error:
Error: "
The second is:
"OSRM returned an error:
Error: Unable to parse: GEOMETRYCOLLECTION(LINESTRING"...(followed by coordinate pairs)
"GEOS reported: "IllegalArgumentException: point array must contain 0 or >1 elements"
Any help interpreting these errors would be much appreciated.
Hi There,
Thank you for the awesome package first of all! Really helpful!
I am trying to obtain an area around this particular coordinate in London with the following code:
test <- osrmIsochrone(loc = c(0.0370781,51.48189), breaks = seq(from = 0,to=8,by=8))
I am not sure why but this is giving the following error:
The OSRM server returned an error:
Error: InvalidInput
Coordinate is invalid: -9.4e-05,51.407237
The OSRM server returned an error:
Error: InvalidInput
Coordinate is invalid: -9.4e-05,51.458735
The OSRM server returned an error:
Error: InvalidInput
Coordinate is invalid: -9.4e-05,51.510175
Error in UseMethod("st_as_sf") :
no applicable method for 'st_as_sf' applied to an object of class "NULL"
Any advice would be appreciated!
Thank you so much!
Hi,
I have done tests with options(osrm.profile = "walk") but I do not see that it's working, it keeps sending me the route driving.
Thank you
In package osrm version 3.0.0
try:
data("com")
trips <- osrmTrip(loc = com[1101:1150, c(1,3,4)])
Error is on line 134-136 of file osrmTrip.R
:
df <- data.frame(start, end,
duration = res$trips[nt,]$legs[[1]][,3] / 60,
distance = res$trips[nt,]$legs[[1]][,4] / 1000)
The distance column in the returned seems to have changed order in the json
Potential solution, replace 134-136 with
df <- data.frame(start, end,
duration = res$trips[nt,]$legs[[1]][,3] / 60,
distance = res$trips[nt,]$legs[[1]][,2] / 1000)
or alternatively
df <- data.frame(start, end,
duration = res$trips[nt,]$legs[[1]][,"duration"] / 60,
distance = res$trips[nt,]$legs[[1]][,"distance"] / 1000)
Immediate error message
Thanks for this awesome package, I use it a lot to get road distances for my current project. I used to get error messages like this usually if I sent many coordinate pairs (approx. 10000) but since a week ago I immediately get the following message, without any distances/duration returned:
OSRM returned an error:
Error in if (res$code != "Ok") {: argument is of length zero
Error in osrm@data :
trying to get slot "data" from an object of a basic class ("NULL") with no slots
I think it was a API thing before but since it doesn’t work at all anymore, maybe you have any advice how to deal with it?
If it helps, here’s the code I send (to get all IDs I need I write all results into a dataframe, didn't use to be a problem before either):
dist <- data.frame(CID=distdat$CID, zipstart=distdat$zip, ptend=distdat$id, duration=NA, length=NA)
for (i in 1:15000)
{ osrm <- osrmRoute (src = distdat[i, c("zip","x","y")],
dst = distdat[i, c("id","long","lat")], sp="TRUE")
dist[i,4] <- osrm@data[1,3]
dist[i,5] <- osrm@data[1,4]
}
THANK YOU!!
Hi,
I have been working for awhile with various isochrone generation tools and techniques and tumbled upon this blog post:
http://kuanbutts.com/2017/12/16/osmnx-isochrones/
Do you think it is viable to try doing the isochrone generation in the osrm package for R using the igraph package ( https://github.com/igraph/rigraph ) ? The end result seems very precise and professional. Current isochrone maps produced by osrm and galton ( https://github.com/urbica/galton ) look very nice, but the lie a little bit about the real reachability of places.
Hi there,
Thank you! This solved the error.
However, I ran into another problem with this set of coordinates, also in London:
test <- osrmIsochrone(loc = c(-2.4529553,52.71386),
breaks = seq(from = 0,to=8,by=8))
For this, the error is:
Error in .as_Spatial(from, cast, IDs) :
conversion from feature type sfc_GEOMETRY to sp is not supported
This same error occurs for other few sets of coordinates that I have too.
Not sure what this means. Would appreciate your help, thank you!!
Originally posted by @jiaweniscute in #44 (comment)
I just saw this project, you might want to take a look: polyline-to-geojson
Especially considering @barryrowlingson wrote a lot of R packages, he might try to develop a custom package for this decoding task, and you could work with him on this.
Would it be possible to include an option for users to set the speed in the osrmIsochrone function (to not be limited to using the defaults)?
The reason I ask is that when I ran the code for a 10 minute walk time and plotted the result (see below), the resulting Isochrone extends to the edges of the grid, which makes me question whether the grid is capturing the whole 10 minute walk time area or just what fits in the grid. I hypothesize that the walk speed is too slow and therefore the resulting grid is too small to capture the whole walk time.
A related question, are the units for speed in feet per minute? If so, for walk time that equates to about 1.9 mph, whereas (from the quick internet search I did) an average walk speed is about 3 mph.
options(osrm.profile = "walk")
iso <- osrmIsochrone(loc = c(28.307913, -15.396259), breaks = seq(from = 0, to = 10, by = 10), res = 100)
Cannot install package on Ubunutu 18
install.packages('osrm', dependencies=TRUE)
Installing package into ‘/home/grosati/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/osrm_3.3.2.tar.gz'
Content type 'application/x-gzip' length 24411 bytes (23 KB)
==================================================
downloaded 23 KB
The downloaded source packages are in
‘/tmp/Rtmp4cvRTD/downloaded_packages’
`> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=es_AR.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=es_AR.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=es_AR.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=es_AR.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.6.3 tools_3.6.3 `
When I run osrmIsochrone
for a set of points in Alaska, it returns some impossible results. I'm running a local osrm server based on https://download.geofabrik.de/north-america/us/alaska-latest.osm.pbf
options(osrm.server = "http://localhost:5000/") #this works sort of
isochrone <- map2(latlon$lon, latlon$lat,
~ osrmIsochrone(loc = c(.x, .y),
breaks = seq(0, 60, 60))) %>%
do.call(what = rbind)
At first, the results look plausible:
But on closer inspection, they don't make any sense. Here, for example, is Sitka, Alaska:
What I'm doing here is plotting the service area (60 minutes' driving time) for a facility (orange dot) as compared with the census tracts for the area. The isochrone for the service area is blue; the different census tracts are in purple/green. I have confirmed that the proj4string
s for both the census tract polygons and the isochrones are exactly the same.
What doesn't make sense about the isochrone plotted in the image above is that the roads around Sitka, Alaska, don't extend for more than 10 miles. There's no way that you could traverse Baranof Island and reach the next island to the east simply by driving for an hour. There's no roads. Also, there's a mountain range and a sea strait in the way. The inaccuracy of the isochrone affects my analysis, because it would suggest that I include a census tract in the Sitka facility's service area which, in fact, is not reachable within a 60 minute drive.
So I used the osrm-frontend
to look up what osrm-backend
is doing. Here's the route it gives me when I try to plot a course from Sitka to the eastern side of Baranof Island:
It would take three days to hike from the end of the road, as pictured above, to the eastern side of Baranof Island. But the directions given above don't mention that — and osrmIsochrone
, for a reason I can't determine, believes you can drive all the way to the next island within 60 minutes.
Additionally, the isochrones for Anchorage suggest that most of Anchorage Bay is driveable. It is not, even in winter. Here's a plot of the facilities without isochrones:
Here's the facilities' 60-minute isochrones, suggesting a drive into the bay:
I still have isochrones for facilities in 49 other states to plot, so I don't know if the issue is with the map, or with osrmIsochrone
, or with osrm-backend
, but this is not an auspicious start. I have some doubts that isochrones produced for the facilities in the other 49 states would be analytically valid.
I read about how the OSRM could be used to solve the Traveling Salesman Problem (TSP). https://medium.com/@janakachathuranga/leaving-google-maps-use-osrm-for-routing-aa1afc912df3
I can not find how this can be implemented in R using the OSRM. I need help with this. Thanks
Hello,
Given that osrm interfaces OSM, is that possible with osrm to specify the mean of transportation and to get the details of the trip? (ex: walk 2min, then bus 4 during 15min, then walk 1 min) ?
Thanks,
Xavier
When I run the code :
# Load data
data("com")
# Travel path between points
route <- osrmRoute(src = com[1, c("comm_id", "lon","lat")],
dst = com[15, c("comm_id", "lon","lat")])
I get the following error:
osrmRoute function returns an error:
Error: parse error: premature EOF
(right here) ------^
I looked around and found that it could be the OSM server - perhaps this is indeed it. You refer to this site: https://github.com/Project-OSRM/osrm-backend/wiki/Building-OSRM
But you don't say how to use it, once I have the repo cloned, then what? How do I "link" R to this?
I am sorry, I am not a full stack coder, this goes beyond my skill level and would really appreciate some help.
Thanks!
Hi,
I'm running my own OSRM server.
I'd like to get travel distance isochrones from osrmIsochrone()
. Looking at the code I see that osrmTable has a measure
argument, but osrmIsochrone()
has a lot of hard coded variable names for the "duration"
run, and most likely a variety of other hard coded duration based features.
Would it be possible to add "distance" to osrmIsochrone()
? If it's a matter of rewriting some parts of the function, I can offer my help. I did try the rewrite some parts to allow for "distance", but I didn't get it to work.
Hello.
How do I add location along the path of travel so that I can get my route plotted at those points as well.
I'd appreciate a solution to this question. Thanks'
Originally posted by @Anyaoha in #33 (comment)
How many requests can be made? I have about 500 points and I would like to check the time and distance between each point, is there a problem if I make the request? It will be about 500*499/2 single requests.
Hello,
I'm trying to use osrmRoute, but it returned me an error with this messages: "Error: parse error: premature EOF". And I don't know what happens. It even happens with documentation's example.
I'm using version 3.0.0 from CRAN.
Thanks.
I'm trying to use rCarto/osrm with my local osrm server, but the url looks malformed:
OSRM returned an error:
Error: InvalidUrl
URL string malformed close to position 4: "v1/dri"
the osrm log output:
15-12-2017 23:05:02 5.59688ms 172.17.0.1 - 'osrm' R package 400 /v1/driving/
according to https://github.com/Project-OSRM/osrm-backend//docs/http.md
the {service} should come first.
Do you understand the following error:
> options(osrm.server = "http://router.project-osrm.org/")
> iso <- osrm::osrmIsochrone(loc = c(5.936036, 49.24882), breaks = seq(from = 0, to = 15, length.out = 3))
Error in rbind2(..1, r) : no method for coercing this S4 class to a vector
or
> options(osrm.server = "http://router.project-osrm.org/")
> iso <- osrm::osrmIsochrone(loc = c(5.936036, 49.24882), breaks = seq(from = 0, to = 15, length.out = 3))
Error in rbind2(..1, r) : no method for coercing this S4 class to a vector
Thank you very much for your support,
Christoph
Hello, I try to use the osrm package in R to get the travel time matrix. I tried with both my own dataset and the example in README. Both time I got a travel time matrix (duration) equal zero
`data("com")
distCom <- osrmTable(loc = com[1:50, c("comm_id","lon","lat")])
distCom$durations[1:5,1:5]
FR3162292119 FR3162212035 BE241011 BE241024 FR3162270520
FR3162292119 0 0 0 0 0
FR3162212035 0 0 0 0 0
BE241011 0 0 0 0 0
BE241024 0 0 0 0 0
FR3162270520 0 0 0 0 0`
Then I check distcom$destinations and distcom$sources, found they all have the same coordination.
` distCom$destinations[1:5,]
lon lat
FR3162292119 -114.1306 34.27882
FR3162212035 -114.1306 34.27882
BE241011 -114.1306 34.27882
BE241024 -114.1306 34.27882
FR3162270520 -114.1306 34.27882
distCom$sources[1:5,]
lon lat
FR3162292119 -114.1306 34.27882
FR3162212035 -114.1306 34.27882
BE241011 -114.1306 34.27882
BE241024 -114.1306 34.27882
FR3162270520 -114.1306 34.27882
com[1:5,]
comm_id name lon lat
1 FR3162292119 Bethune 2.647810 50.51990
2 FR3162212035 Annezin 2.619300 50.54150
3 BE241011 Denderleeuw 4.071241 50.88721
4 BE241024 Haaltert 4.005772 50.90225
5 FR3162270520 Locon 2.666170 50.57050`
can you please tell me what went wrong?
Hi Timothée,
I realised that I am getting different isochrones for the same coordinates and parameters that I input. For example, the code below gave me 2 different isochrones. One query was done last month at night and the second query was done today afternoon.
iso <- osrmIsochrone(loc = c(-1.3583549, 50.91489),
breaks = seq(from = 0,to=8,by=8),
returnclass = "sf")
Why is this? Is the formation of the isochrones time-dependent? Meaning that it depends on the time of the day that I query it? Couldn't find the answer to this on the official documentation.
Would appreciate your help!
Thank you!!
I used the following
osrmIsochrone(c(-95.9345,41.2565), breaks = 10)
and received this error
The OSRM server returned an error:
Error: lexical error: invalid char in json text.
<HTML><HEAD> <TITLE>Request Er
(right here) ------^
The OSRM server returned an error:
Error: lexical error: invalid char in json text.
<HTML><HEAD> <TITLE>Request Er
(right here) ------^
The OSRM server returned an error:
Error: lexical error: invalid char in json text.
<HTML><HEAD> <TITLE>Request Er
(right here) ------^
Error in UseMethod("st_as_sf") :
no applicable method for 'st_as_sf' applied to an object of class "NULL"```
If I run the osrmIsochrone()
function then the code breaks. See below:
suppressPackageStartupMessages(library(osrm))
# Load data
data("com")
# Get isochones with a SpatialPointsDataFrame, custom breaks
iso <- osrmIsochrone(loc = src[6,], breaks = seq(from = 0,to = 30, by = 5))
## Error in rbind2(..1, r): no method for coercing this S4 class to a vector
sessionInfo()
## R version 3.3.3 (2017-03-06)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 16.04.2 LTS
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] osrm_3.0.1
##
## loaded via a namespace (and not attached):
## [1] gepaf_0.1.0 Rcpp_0.12.10 lattice_0.20-35 digest_0.6.12
## [5] rprojroot_1.2 bitops_1.0-6 grid_3.3.3 jsonlite_1.3
## [9] backports_1.0.5 magrittr_1.5 evaluate_0.10 stringi_1.1.2
## [13] raster_2.5-8 sp_1.2-4 rmarkdown_1.3 rgdal_1.2-5
## [17] tools_3.3.3 stringr_1.2.0 RCurl_1.95-4.8 yaml_2.1.14
## [21] rgeos_0.3-23 htmltools_0.3.5 knitr_1.15.1
I executed following R codes.
library(osrm)
data("com")
iso <- osrmIsochrone(loc = src[6,], breaks = seq(from = 0,to = 30, by = 5))
but I got a following error when using osrmIsoChrone function
osrmTable function returns an error:
Error: Something went wrong. It could be that the URL sent to the OSRM public API is too long.
Try to enter less sources or destinations.
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘coordinates’ for signature ‘"NULL"’
My sessionInfo is as follows.
> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=Japanese_Japan.932 LC_CTYPE=Japanese_Japan.932 LC_MONETARY=Japanese_Japan.932 LC_NUMERIC=C
[5] LC_TIME=Japanese_Japan.932
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] osrm_3.0.1
loaded via a namespace (and not attached):
[1] compiler_3.4.0 rgdal_1.2-7 tools_3.4.0 RCurl_1.95-4.8 sp_1.2-4 grid_3.4.0 bitops_1.0-6 gepaf_0.1.0
[9] lattice_0.20-35
Could you tell me what I should?
The osrmTable() and osrmTableOD() commands to my local server are still limited to 100, even when using the limit function to increase the limit:
table2 <- osrmTable(distance[1:100,], id = "URN", x = "Long", y = "Lat")
table3 <- osrmTable(distance[1:101,], id = "URN", x = "Long", y = "Lat")
osrmTable function returns an error:
Error in dimnames(mat) <- list(df[, id], df[, id]): attempt to set an attribute on NULL
With the limit function to increase the limit:
travel.times <- osrmTableOD(dfo = distance[1:520,], ido = "URN", xo = "Long", yo = "Lat", dfd = distance[1:520,], idd = "nid", xd = "NLong", yd = "NLat", limit = 3257)
osrmTable function returns an error:
Error in dimnames(mat) <- list(df[, id], df[, id]): attempt to set an attribute on NULL
Is there something else that I need to change to get around this limit?
Hi, I am a fish biologist tracking fish species via detection stations in various waterways such as rivers, canals and ditches. I would like to calculate the swim distance between the subsequent detection stations in the waterways. Is there any way to do it with this package?
No routes are returning for my points. The below is an example of two points I'm trying to map.
> route <- osrmRoute(src = c(1, 40.39956, -79.98636 ), dst = c(2, 40.38693, -79.98355), overview = F) The OSRM server returned an error: Error: NoRoute No route found
Any assistance would be appreciated.
Just trying this out and getting an error:
origin = tmap::geocode_OSM("Bradford")
destination = tmap::geocode_OSM("Leeds")
ro = osrmRoute(origin, destination)
osrmRoute function returns an error:
Error: URL string malformed close to position 31: "73, 51"
Any ideas?
Since the OSRM Demo Server is down and the Mapbox API is used as the official OSRM demo instead. It is not clear for me how can I use this API through the osrm-package?
Hi, first off, thanks for the awesome package!
I'm new to this package and have been experimenting with osrm . I tried the example code for osrmTable(). Namely:
data("com")
distCom2 <- osrmTable(src = com[1:10,c("comm_id","lon","lat")],
dst = com[11:20,c("comm_id","lon","lat")])
This exact code worked just fine yesterday, however, when I try now, it is giving me this error:
osrmTable function returns an error:
Error: The URL sent to the OSRM public API is too long. Enter less
sources or destinations.
I tried reducing the number of sources & destinations to one:
home = data.frame(001, -118.454642, 34.069432)
work = data.frame(002, -118.260938, 34.049268)
test = osrmTable(src=home, dst=work)
however, I am still receiving the same error. Trying all the other example codes within osrmTable() such as:
distCom <- osrmTable(loc = com[1:50, c("comm_id","lon","lat")])
also gives me the same error. I was hoping you could help me figure out a solution to this error and hopefully explain why this error did not appear before. Thanks in advance!
Hey! Is there any possibility of getting an isometric map, with diriving distance rings instead of driving time?
Dear rCarto,
Would it be possible to implement some sort of option "type = c("car", "bike", "foot")" to the osrmRoute function?
I get the following error message when I try to generate isochrones for the point given below (in Bethel, Alaska):
iso <- osrmIsochrone(loc = c(-161.8703202,60.76931), breaks = seq(from = 0,to = 60, by = 20))
Error in if (any(idx)) { : missing value where TRUE/FALSE needed
When I try adjusting the to
and by
values to less than 10 minutes (e.g. to = 60, by = 20)
), the command works. I suspect this is because the roads in Bethel, Alaska, don't extend much beyond 10 minutes of travel time. Can you confirm that this is the reason for the error message?
If this is so, I would have expected that osrmIsochrone
would at least return the isochrones for which there were non-missing, valid travel times. Or an option so that I could set osrmIsochrone
to return the maximum travel time within a closed road network, given certain min/max/break parameters.
And perhaps a more descriptive error message.
If I have to plot 1,000 isochrones within Alaska, Hawaii, or other isolated areas for analysis, this is an error that's going to come up a lot — without a clear or systematic way of resolving it yet.
Hello,
I'm a new user of the package and love it so far, thank you!!
I do have a question if I can use osrmRoute to get multiple distances? I have a table of a couple of 100 coordinates from -> to. So a Matrix is out.
Data structure of a is ID, x, y, Long, lat (with x and y being the source coordinates and Long, lat being the Destination coordinates). The function works perfectly with just one row, but as soon as I ask for 2 rows I get an error message
route <- osrmRoute (src = a[1:2, c("id","x","y")],
dst = a[1:2, c("id","long","lat")], overview="simplified", sp="TRUE")
osrmRoute function returns an error:
Error: URL string malformed close to position 32: "23, 13"
since I only Need the distance(and maybe minutes, but not neccessarily), is there a way get those for multiple lines?
Thank you!
Lina
It seems inevitable and desirable.
I've increased the maximum table size on my local server as
osrm-routed china-latest.osrm --max-table-size=1000
but I still cannot use osrmTable() for more than ~200 locations (it fails somewhere between 201 and 250). The error I get is:
osrmTable function returns an error: Error: lexical error: invalid char in json text. <html> <head><title>414 Reques (right here) ------^
The test example I've used:
library(osrm)
max_lat <- 40
min_lat <- 30
max_long <- 117
min_long <- 104
n <- 201
long <- runif(n,min=min_long,max=max_long)
lat <- runif(n,min=min_lat,max=max_lat)
names <- as.character(n)
china_mat <- data.frame(names,long,lat,stringsAsFactors = FALSE)
results <- osrmTable(china_mat,locId = "names",locLat = "lat",locLon = "long")
I can see from the server, that when osrmTable fails, the server does not get any request.
What could be causing this issue? This question is somewhat related to the older issue #4.
i have for example, loc = c(2.7353, 46.9514), duration = 45, res = 10 gives incorrect result coords 5 points
but when we change de res = 45 we get the correct result between 15 and 20 points
After an update from
sessionInfo("osrm")$otherPkgs
$`osrm`
Version: 3.1.1
Date: 2018-03-12
to
$`osrm`
Version: 3.3.2
we receive the following error:
Data: (c) OpenStreetMap contributors, ODbL 1.0 - http://www.openstreetmap.org/copyright
Routing: OSRM - http://project-osrm.org/
Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
The OSRM server returned an error:
Error: InvalidQuery
Query string malformed close to position 6249
Do you have any idea? Our call (as before the update) is of the type
osrm::osrmIsochrone(c(lngs[i], lats[i]), breaks, res)
The same code runs through without any error.
Please let me know, if you need anything else. Thanks a lot!
Hello, I am a happy user of osrm's R package.
I am trying to get a matrix of distances and a matrix of durations between 4000 points.
The matrix of duration is easy to get. I can use the osrmTable function to get the duration of multiple start points and multiple destinations.
However, for the distance, I can only get one value of distance between two points every execution of osrmRoute() function. It will take weeks for me to get the entire matrix.
Could you please tell me if there's a better way to get the matrix of distances?
Great package, very impressed, planning to use this as a backend in stplanr. One thing that would help that is if src
and dst
could take vectors, not just spatial object. Demo of what I mean below. cc @richardellison who may be up for helping with this:
library(osrm)
#> Data: (c) OpenStreetMap contributors, ODbL 1.0 - http://www.openstreetmap.org/copyright
#> Routing: OSRM - http://project-osrm.org/
library(stplanr)
#> Registered S3 method overwritten by 'R.oo':
#> method from
#> throw.default R.methodsS3
options(osrm.server = "http://0.0.0.0:5000/", osrm.profile = "driving")
l = pct::wight_lines_30
p = line2points(l)
r = osrm::osrmRoute(src = p[1, ], dst = p[2, ], returnclass = "sf")
plot(r)
route_osrm2 = function(l) {
p = line2points(l)
s = (1:nrow(l)) * 2 - 1
list_out = lapply(s, function(i) osrm::osrmRoute(p[i, ], dst = p[i + 1, ], returnclass = "sf"))
do.call(rbind, list_out)
}
routes_osrm = route_osrm2(l)
plot(routes_osrm)
# with coordinates
c1 = as.numeric(sf::st_coordinates(p[1, ]))
c2 = as.numeric(sf::st_coordinates(p[2, ]))
osrm::osrmRoute(src = c1, dst = c2, returnclass = "sf")
#> The OSRM server returned an error:
#> Error: InvalidQuery
#> Query string malformed close to position 27
#> NULL
Created on 2019-09-20 by the reprex package (v0.3.0)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.