Comments (5)
I managed to create the cross product of all origins and destinations pairs but still not sure on how to use that to run detailed_itineraires for all combinations. What would be the right arguments to do so?
from r5r.
please follow the example below:
library(r5r)
library(data.table)
library(dplyr)
# build transport network
data_path <- system.file("extdata/poa", package = "r5r")
r5r_core <- setup_r5(data_path = data_path, temp_dir = TRUE)
# Read points
origins <- read.csv(file.path(data_path, "poa_points_of_interest.csv"))[1:4,]
destinations <- read.csv(file.path(data_path, "poa_points_of_interest.csv"))[3:10,]
# get all possible combinations between origins and destinations
# function
get_all_od_combinations <- function(origins, destinations){
# all possible id combinations
base <- expand.grid(origins$id, destinations$id)
# rename df
setDT(base)
setnames(base, 'Var1', 'idorig')
setnames(base, 'Var2', 'iddest')
# bring spatial coordinates from origin and destination
base[origins, on=c('idorig'='id'), c('lon_orig', 'lat_orig') := list(i.lon, i.lat)]
base[destinations, on=c('iddest'='id'), c('lon_dest', 'lat_dest') := list(i.lon, i.lat)]
return(base)
}
df <- get_all_od_combinations(origins, destinations)
# select/rename columns for r5r input
all_orig <- dplyr::select(df, c('id'=idorig, 'lon'=lon_orig,'lat'=lat_orig))
all_dest <- dplyr::select(df, c('id'=iddest, 'lon'=lon_dest,'lat'=lat_dest))
# run r5r
departure_datetime <- as.POSIXct("13-05-2019 14:00:00", format = "%d-%m-%Y %H:%M:%S")
dit <- detailed_itineraries(r5r_core,
origins = all_orig,
destinations = all_dest,
mode = c("WALK", "TRANSIT"),
departure_datetime = departure_datetime,
max_walk_dist = 1000,
max_trip_duration = 30)
from r5r.
This is related to #224.
The dev version of the detailed_itineraries()
function now has a new parameter all_to_all
, which allows users to set whether they want to query routes between all origins to all destinations (all_to_all = TRUE
) or to query. By default (FALSE
), the functions queries routes between the the 1st row of origins to the 1st row of destinations, then the 2nd row of origins to the 2nd row of destinations, and so on.
from r5r.
@rafapereirabr how do I access the dev version? This new parameter would be really helpful.
from r5r.
You can install the dev verison with the code below:
utils::remove.packages('r5r')
devtools::install_github("ipeaGIT/r5r", subdir = "r-package")
library(r5r)
from r5r.
Related Issues (20)
- Trouble Installing R5R in R: Fatal error HOT 2
- Error testing R5 v7.1 - does not have member field 'int maxDestinations' HOT 1
- Error in .jcall("RJavaTools", "Z", "hasField", .jcast(x, "java/lang/Object"), : java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "<parameter1>" is null HOT 39
- Update required JDK version in Getting Started vignette HOT 6
- r5r v2.0 on CRAN HOT 1
- Isochrones in low-road density contexts HOT 7
- network.dat not built after running setup_r5 HOT 8
- Recurring issue from issue #382: Isochrones in low-road density contexts HOT 1
- Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException HOT 4
- Code redundancy in R5TravelTimeComputer
- convinient function to check Java version HOT 9
- Transit mode not used, problems with GTFS data? HOT 9
- Error using setup_r5() HOT 3
- Errors with setup_r5() HOT 10
- Issues with travel_time_matrix including reasonable transit times HOT 1
- r5r Not recognizing Java Version HOT 21
- Initialize_r5r_core HOT 15
- java.lang.ArrayIndexOutOfBoundsException error when calling accessibility HOT 6
- Max Walk Time HOT 3
- Catchments at different times HOT 3
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 r5r.