Comments (10)
Hello,
Thank you for raising this issue.
Are you using your own OSRM server ? With the driving profile?
Also, it would be helpful to have the values of i, lngs, lats, breaks and res.
from osrm.
Hi, Thanks for your reply. Don't hestite to conatct me, in case you need further details:
the data (from RStudio)
structure(list(PLZ = NA, Stadt = "Erstfeld", Breite = 46.81236378,
Laenge = 8.599465297), class = "data.frame", row.names = c(NA,
-1L))
The relevant code sequence:
library(osrm)
library(sf)
res_isochrones <- 50
breaks_isochrones <- seq(90, 120, 30)
path <- paste0(getwd(), "/rawdata/")
map_name = "switzerland-latest"
osrm_path = "C:/OSRM_API5"
filename <- paste0(path, "LagerErstfeld.csv")
datenLager <- read.csv(filename, sep = ";", stringsAsFactors = FALSE)
r <- calculate_isochones(names = datenLager$PLZ, lats = datenLager$Breite[1],
lngs = datenLager$Laenge[1],
breaks = breaks_isochrones,
res = res_isochrones,
map_name = map_name,
osrm_path = osrm_path)
calculate_isochones <- function(names, lats, lngs, breaks = seq(5,20,5), res = 50,
map_name, osrm_path) {
options(osrm.server = paste0(osrmr:::server_address(TRUE), "/"), osrm.profile = "driving")
osrmr::run_server(paste0(map_name, ".osrm"), osrm_path)
parameters <- list(Names = names,
Lattitudes = lats,
Longitudes = lngs,
Breaks = breaks,
Resolution = res)
isochrone_list <- list()
for (i in 1:length(lats)) {
isochrone_list[[i]] <- osrm::osrmIsochrone(c(lngs[i], lats[i]), breaks, res)
}
names(isochrone_list) <- names
isochrone_list <- list(parameters, isochrone_list)
osrmr::quit_server()
return(isochrone_list)
}
We use R and a local version of OSRM running on Windows (API5).
The API seems find and I figured out, that in your function, everything seems to be ok until req <- tableLoc(loc = loc, gepaf = gepaf)
in osrmTable()
.
from osrm.
Ok I see it.
Since v3.2.0, a new parameter has been added in osrmIsochrone()
(exclude
, between breaks
and res
) .
I you use explicitly named argument the function should work. Something like :
osrm::osrmIsochrone(loc = c(lngs[i], lats[i]), breaks = breaks, res = res)
Sorry for the breaking change, I should have added the new param at the end of the list...
from osrm.
Still the same issue in
isochrone_list[[i]] <- osrm::osrmIsochrone(loc = c(lngs[i], lats[i]),
breaks = breaks, res = res)
results in
The OSRM server returned an error:
Error: InvalidQuery
Query string malformed close to position 6309
8x the same message...
Error in UseMethod("st_as_sf") :
no applicable method for 'st_as_sf' applied to an object of class "NULL"
from osrm.
from osrm.
Using the demo server and the coordinates you sent me I get:
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.7.1, GDAL 2.4.0, PROJ 5.2.0
res <- 50
breaks <- seq(90, 120, 30)
loc <- c(8.599465297, 46.81236378)
iso <- osrmIsochrone(loc = loc, breaks = breaks,
res = res, returnclass = "sf")
plot(st_geometry(iso), col = c("lightblue1", "lightblue3"))
points(loc[1], loc[2], pch = 20, col = "red")
Created on 2019-10-04 by the reprex package (v0.3.0)
But I don't know what's in the "LagerErstfeld.csv" file...
from osrm.
Ok, so it is definitely related to the local OSRM:
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.6.1, GDAL 2.2.3, PROJ 4.9.3
res <- 50
breaks <- seq(90, 120, 30)
loc <- c(8.599465297, 46.81236378)
iso <- osrmIsochrone(loc = loc, breaks = breaks,
res = res, returnclass = "sf")
plot(st_geometry(iso), col = c("lightblue1", "lightblue3"))
points(loc[1], loc[2], pch = 20, col = "red")
Everything works!
Then:
map_name = "switzerland-latest"
osrm_path = "C:/OSRM_API5"
options(osrm.server = paste0(osrmr:::server_address(TRUE), "/"), osrm.profile = "driving")
osrmr::run_server(paste0(map_name, ".osrm"), osrm_path) # a wrapper for a shell command. See below...
res <- 50
breaks <- seq(90, 120, 30)
loc <- c(8.599465297, 46.81236378)
iso <- osrmIsochrone(loc = loc, breaks = breaks,
res = res, returnclass = "sf")
# The OSRM server returned an error:
# Error: InvalidQuery
# Query string malformed close to position 6285
...
Error in UseMethod("st_as_sf") :
no applicable method for 'st_as_sf' applied to an object of class "NULL"
From our local API (Which is working, this is the command from osrmr::run_server()
):
C:\OSRM_API5>osrm-routed switzerland-latest
[info] starting up engines, v5.10.0[0m
[info] Threads: 8[0m
[info] IP address: 0.0.0.0[0m
[info] IP port: 5000[0m
[info] load names from: "switzerland-latest.osrm.names"[0m
[info] set checksum: 384967193[0m
[info] http 1.1 compression handled by zlib version 1.2.8[0m
[info] Listening on: 0.0.0.0:5000[0m
[info] running and waiting for requests[0m
I hope that helps! I already checked, whether the OSRM API interfaced changed since 5.10, but I couldn't find anything.
from osrm.
So that's it, I try to keep the osrm package in line with the latest version of OSRM served via Docker (name: latest in images on Docker Cloud, https://github.com/Project-OSRM/osrm-backend#using-docker). The version announced is currently 5.22.0.
In version 5.18.0 (https://github.com/Project-OSRM/osrm-backend/blob/master/CHANGELOG.md#5180) a new param annotation
has been added to the table service.
Accordingly osrmTable()
gained this new parameter. Changing things around here: https://github.com/rCarto/osrm/blame/master/R/osrmTable.R#L118 would probably solve your problem.
I do not plan to modify the package to work with older version of OSRM (v.5.18.0 is from 10 May 2018, v5.10.0 is from 7 Aug 2017).
The strategy with osrm
is to follow the latest version and the demo version of OSRM.
My suggestion here would be to update OSRM to the latest version (and I guess it could be bothersome in Window$ OS...). Or to use an old version of osrm
(but, notably, osrmIsochrone()
has improved with the last 2-3 verisons).
from osrm.
Thanks again for your great support! I understand and I consider this issue as solved.
from osrm.
All right
from osrm.
Related Issues (20)
- How can I remove alternate routes when using osrm package in leaflet(r)? HOT 1
- Improve error handling osrmIsochrone(): out of bounds
- 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
- Error in `osrmTrip()` when location coordinates are close to each other and/or not on roads HOT 2
- 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
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.