Title: | Setup and connect to 'OpenTripPlanner' |
---|---|
Description: | Setup and connect to 'OpenTripPlanner' (OTP) <http://www.opentripplanner.org/>. OTP is an open source platform for multi-modal and multi-agency journey planning written in 'Java'. The package allows you to manage a local version or connect to remote OTP server to find walking, cycling, driving, or transit routes. This package has been peer-reviewed by rOpenSci (v. 0.2.0.0). |
Authors: | Malcolm Morgan [aut, cre] , Marcus Young [aut] , Robin Lovelace [aut] , Layik Hama [ctb] |
Maintainer: | Malcolm Morgan <[email protected]> |
License: | GPL-3 |
Version: | 0.5.2 |
Built: | 2024-11-27 03:24:37 UTC |
Source: | https://github.com/ropensci/opentripplanner |
The goal of OpenTripPlanner for R is to provide a simple R interface to OpenTripPlanner (OTP). The OTP is a multimodal trip planning service.
Maintainer: Malcolm Morgan [email protected] (ORCID)
Authors:
Marcus Young [email protected] (ORCID)
Robin Lovelace [email protected] (ORCID)
Other contributors:
Layik Hama [email protected] (ORCID) [contributor]
Useful links:
Report bugs at https://github.com/ropensci/opentripplanner/issues
Example JSON response from OTP This is used for internal testing and has no use
json_example_drive
json_example_drive
json
Example JSON response from OTP This is used for internal testing and has no use
json_example_long_drive
json_example_long_drive
json
Example JSON response from OTP This is used for internal testing and has no use
json_example_transit
json_example_transit
json
OTP is run in Java and requires Java commands to be typed into the command line. The function allows the parameters to be defined in R and automatically passed to Java. This function builds a OTP graph from the Open Street Map and other files.
otp_build_graph( otp = NULL, dir = NULL, memory = 2048, router = "default", flag64bit = TRUE, quiet = TRUE, otp_version = NULL )
otp_build_graph( otp = NULL, dir = NULL, memory = 2048, router = "default", flag64bit = TRUE, quiet = TRUE, otp_version = NULL )
otp |
A character string, path to the OTP .jar file |
dir |
A character string, path to a directory containing the necessary files, see details |
memory |
A positive integer. Amount of memory to assign to the OTP in MB, default is 2048 |
router |
A character string for the name of the router, must subfolder of dir/graphs, default "default". See vignettes for details. |
flag64bit |
Logical, if true the -d64 flag is added to Java instructions, ignored if otp_version >= 2 |
quiet |
Logical, if FALSE the Java commands will be printed to console |
otp_version |
Numeric, version of OTP to build, default NULL when version is auto-detected |
The OTP .jar file can be downloaded from https://repo1.maven.org/maven2/org/opentripplanner/otp/
To build an OTP graph requires the following files to be in the directory specified by the dir variable.
/graphs - A sub-directory
/default - A sub-directory with the name of the OTP router used in router' variable
osm.pbf - Required, pbf file containing the Open Street Map
router-config.json - Required, json file containing configurations settings for the OTP
gtfs.zip - Optional, and number of GTFS files with transit timetables
terrain.tif - Optional, GeoTiff image of terrain map
The function will accept any file name for the .jar file, but it must be the only .jar file in that directory OTP can support multiple routers (e.g. different regions), each router must have its own sub-directory in the graphs directory
Character vector of messages produced by OTP, and will return the message "Graph built" if successful
Other setup:
otp_check_java()
,
otp_check_version()
,
otp_dl_demo()
,
otp_dl_jar()
,
otp_make_config()
,
otp_setup()
,
otp_stop()
,
otp_validate_config()
,
otp_write_config()
## Not run: log <- otp_build_graph(otp = "C:/otp/otp.jar", dir = "C:/data") ## End(Not run)
## Not run: log <- otp_build_graph(otp = "C:/otp/otp.jar", dir = "C:/data") ## End(Not run)
Check if you have the correct version of Java for running OTP locally
otp_check_java(otp_version = 1.5)
otp_check_java(otp_version = 1.5)
otp_version |
numeric, OTP version number default 1.5 |
Other setup:
otp_build_graph()
,
otp_check_version()
,
otp_dl_demo()
,
otp_dl_jar()
,
otp_make_config()
,
otp_setup()
,
otp_stop()
,
otp_validate_config()
,
otp_write_config()
Check the what version of OTP the server is running
otp_check_version(otpcon, warn = TRUE)
otp_check_version(otpcon, warn = TRUE)
otpcon |
otpcon object from otp_connect() |
warn |
logical, if TRUE will check that OTP version matches contents of otpcon |
Other setup:
otp_build_graph()
,
otp_check_java()
,
otp_dl_demo()
,
otp_dl_jar()
,
otp_make_config()
,
otp_setup()
,
otp_stop()
,
otp_validate_config()
,
otp_write_config()
Defines the parameters required to connect to a router on an OTP instance and, if required, confirms that the instance and router are query-able.
otp_connect( hostname = "localhost", router = "default", url = NULL, port = 8080, ssl = FALSE, check = TRUE, timezone = Sys.timezone(), otp_version = 1.5 )
otp_connect( hostname = "localhost", router = "default", url = NULL, port = 8080, ssl = FALSE, check = TRUE, timezone = Sys.timezone(), otp_version = 1.5 )
hostname |
A string, e.g. "ec2-34-217-73-26.us-west-2.compute.amazonaws.com". Optional, default is "localhost". |
router |
A string, e.g. "UK2018". Optional, default is "default". OTP can support multiple routers see advanced vignette for details. |
url |
If a non-standard URL structure is used provide a full url, default is NULL |
port |
A positive integer. Optional, default is 8080. |
ssl |
Logical, indicates whether to use https. Optional, default is FALSE. |
check |
Logical. If TRUE connection object is only returned if OTP instance and router are confirmed reachable. Optional, default is TRUE. |
timezone |
Character, timezone, defaults to local timezone |
otp_version |
Numeric, OTP Version in use default 1.5, if check is TRUE then 'otp_check_version()' is called and otp_version is updated |
The default URL structure for the OTP API is: http://<hostname>:<port>/otp/routers/<router> For example: http://localhost:8080/otp/routers/default
Functions construct the URL from the parameters provided in otpconnect
objects. However some websites hosting OTP have modified the default URL
structure. If this is the case you can use the url
parameter to bypass
the URL construction and provide a fully formed URL. In this case the
hostname
, router
, port
, and ssl
are ignored.
Returns an S3 object of class otpconnect. If check
is TRUE and
the router is not reachable the object is not returned.
## Not run: otpcon <- otp_connect() otpcon <- otp_connect( router = "UK2018", ssl = TRUE ) otpcon <- otp_connect( hostname = "ec2.us-west-2.compute.amazonaws.com", router = "UK2018", port = 8888, ssl = TRUE ) otpcon <- otp_connect( url = "https://api.digitransit.fi:443/routing/v1/routers/hsl" ) ## End(Not run)
## Not run: otpcon <- otp_connect() otpcon <- otp_connect( router = "UK2018", ssl = TRUE ) otpcon <- otp_connect( hostname = "ec2.us-west-2.compute.amazonaws.com", router = "UK2018", port = 8888, ssl = TRUE ) otpcon <- otp_connect( url = "https://api.digitransit.fi:443/routing/v1/routers/hsl" ) ## End(Not run)
Download the demonstration data for the Isle of Wight
otp_dl_demo( path_data = NULL, url = paste0("https://github.com/ropensci/opentripplanner/", "releases/download/0.1/isle-of-wight-demo.zip"), quiet = FALSE )
otp_dl_demo( path_data = NULL, url = paste0("https://github.com/ropensci/opentripplanner/", "releases/download/0.1/isle-of-wight-demo.zip"), quiet = FALSE )
path_data |
path to folder where data for OTP is to be stored |
url |
URL to data |
quiet |
logical, passed to download.file, default FALSE |
Other setup:
otp_build_graph()
,
otp_check_java()
,
otp_check_version()
,
otp_dl_jar()
,
otp_make_config()
,
otp_setup()
,
otp_stop()
,
otp_validate_config()
,
otp_write_config()
## Not run: otp_dl_demo(tempdir()) ## End(Not run)
## Not run: otp_dl_demo(tempdir()) ## End(Not run)
Download the OTP jar file from maven.org
otp_dl_jar( path = NULL, version = "1.5.0", file_name = paste0("otp-", version, "-shaded.jar"), url = "https://repo1.maven.org/maven2/org/opentripplanner/otp", quiet = FALSE, cache = TRUE )
otp_dl_jar( path = NULL, version = "1.5.0", file_name = paste0("otp-", version, "-shaded.jar"), url = "https://repo1.maven.org/maven2/org/opentripplanner/otp", quiet = FALSE, cache = TRUE )
path |
path to folder where OTP is to be stored |
version |
a character string of the version number default is "1.5.0" |
file_name |
file name to give the otp default "otp.jar" |
url |
URL to the download server |
quiet |
logical, passed to download.file, default FALSE |
cache |
logical, default TRUE, see details |
As of version 0.3.0.0 'otp_dl_jar' will cache the JAR file within the package and ignore the 'path' argument. You can force a new download to be saved in the 'path' location by setting 'cache = FALSE'.
The path to the OTP file
Other setup:
otp_build_graph()
,
otp_check_java()
,
otp_check_version()
,
otp_dl_demo()
,
otp_make_config()
,
otp_setup()
,
otp_stop()
,
otp_validate_config()
,
otp_write_config()
## Not run: otp_dl_jar(tempdir()) ## End(Not run)
## Not run: otp_dl_jar(tempdir()) ## End(Not run)
Geo-coding converts a named place, such as a street name into a lng/lat pair.
otp_geocode( otpcon = NULL, query = NULL, autocomplete = FALSE, stops = TRUE, clusters = FALSE, corners = TRUE, type = "SF" )
otp_geocode( otpcon = NULL, query = NULL, autocomplete = FALSE, stops = TRUE, clusters = FALSE, corners = TRUE, type = "SF" )
otpcon |
OTP connection object produced by otp_connect() |
query |
Character, The query string we want to geocode |
autocomplete |
logical Whether we should use the query string to do a prefix match, default FALSE |
stops |
Logical, Search for stops, either by name or stop code, default TRUE |
clusters |
Logical, Search for clusters by their name, default FALSE |
corners |
Logical, Search for street corners using at least one of the street names, default TRUE |
type |
Character, How should results be returned can be "SF" or "Coordinates" or "Both", Default "SF" |
OTP will return a maximum of 10 results
Returns a data.frame of SF POINTS or Coordinates of all the locations that match 'query'
Other routing:
otp_isochrone()
,
otp_plan()
,
otp_pointset()
,
otp_routing_options()
,
otp_validate_routing_options()
## Not run: locations <- otp_geocode(otpcon, "High Street") ## End(Not run)
## Not run: locations <- otp_geocode(otpcon, "High Street") ## End(Not run)
Get the Isochrones from a location
otp_isochrone( otpcon = NA, fromPlace = NA, fromID = NULL, mode = "CAR", date_time = Sys.time(), arriveBy = FALSE, maxWalkDistance = 1000, routingOptions = NULL, cutoffSec = c(600, 1200, 1800, 2400, 3000, 3600), ncores = max(round(parallel::detectCores() * 1.25) - 1, 1), timezone = otpcon$timezone )
otp_isochrone( otpcon = NA, fromPlace = NA, fromID = NULL, mode = "CAR", date_time = Sys.time(), arriveBy = FALSE, maxWalkDistance = 1000, routingOptions = NULL, cutoffSec = c(600, 1200, 1800, 2400, 3000, 3600), ncores = max(round(parallel::detectCores() * 1.25) - 1, 1), timezone = otpcon$timezone )
otpcon |
OTP connection object produced by otp_connect() |
fromPlace |
Numeric vector, Longitude/Latitude pair, e.g. 'c(-0.134649,51.529258)', or 2 column matrix of Longitude/Latitude pairs, or sf data frame of POINTS |
fromID |
character vector same length as fromPlace |
mode |
character vector of one or more modes of travel valid values "TRANSIT","BUS", "RAIL", "SUBWAY","TRAM", "FERRY", "GONDOLA", "FUNICULAR", "AIRPLANE", "CABLE_CAR", "WALK", "BICYCLE", "BICYCLE_RENT", "BICYCLE_PARK", "CAR", "CAR_PARK", "CAR_HAIL", "CARPOOL", "CAR_DROPOFF", "CAR_PICKUP", default CAR. Not all combinations are valid e.g. c("WALK","BUS") is valid but c("WALK","CAR") is not. |
date_time |
POSIXct, a date and time, defaults to current date and time |
arriveBy |
Logical, Whether the trip should depart or arrive at the specified date and time, default FALSE |
maxWalkDistance |
maximum distance to walk in metres |
routingOptions |
named list passed to OTP see 'otp_routing_options()' |
cutoffSec |
Numeric vector, number of seconds to define the break points of each Isochrone |
ncores |
number of cores to use in parallel processing |
timezone |
character, timezone to use, default from otpcon |
Isochrones are maps of equal travel time, for a given location a map is produced showing how long it takes to reach each location.
Isochrones are only available from OTP v1.x and will not work with v2.0
Returns a SF data.frame of POLYGONs
Other routing:
otp_geocode()
,
otp_plan()
,
otp_pointset()
,
otp_routing_options()
,
otp_validate_routing_options()
## Not run: isochrone1 <- otp_isochrone(otpcon, fromPlace = c(-0.1346, 51.5292)) isochrone2 <- otp_isochrone(otpcon, fromPlace = c(-0.1346, 51.5292), mode = c("WALK", "TRANSIT"), cutoffSec = c(600, 1200, 1800) ) ## End(Not run)
## Not run: isochrone1 <- otp_isochrone(otpcon, fromPlace = c(-0.1346, 51.5292)) isochrone2 <- otp_isochrone(otpcon, fromPlace = c(-0.1346, 51.5292), mode = c("WALK", "TRANSIT"), cutoffSec = c(600, 1200, 1800) ) ## End(Not run)
OTP can be configured using three json files 'otp-config.json', 'build-config.json', and 'router-config.json'. This function creates a named list for each config file and populates the defaults values.
otp_make_config(type, version = 1)
otp_make_config(type, version = 1)
type |
Which type of config file to create, "otp", "build", "router" |
version |
version of OPT e.g. 1 or 2 |
For more details see: http://docs.opentripplanner.org/en/latest/Configuration
Other setup:
otp_build_graph()
,
otp_check_java()
,
otp_check_version()
,
otp_dl_demo()
,
otp_dl_jar()
,
otp_setup()
,
otp_stop()
,
otp_validate_config()
,
otp_write_config()
{ conf <- otp_make_config("build") conf <- otp_make_config("router") }
{ conf <- otp_make_config("build") conf <- otp_make_config("router") }
Requires OTP 1.x and the analyst
otp_make_surface( otpcon = NULL, fromPlace = c(-1.17502, 50.6459), mode = "CAR", date_time = Sys.time(), maxWalkDistance = 1000, arriveBy = FALSE, routeOptions = NULL, timezone = otpcon$timezone, ncores = 1 )
otp_make_surface( otpcon = NULL, fromPlace = c(-1.17502, 50.6459), mode = "CAR", date_time = Sys.time(), maxWalkDistance = 1000, arriveBy = FALSE, routeOptions = NULL, timezone = otpcon$timezone, ncores = 1 )
otpcon |
OTP connection object produced by otp_connect() |
fromPlace |
Numeric vector, Longitude/Latitude pair, e.g. 'c(-0.134649,51.529258)', or 2 column matrix of Longitude/Latitude pairs, or sf data frame of POINTS with CRS 4326 |
mode |
character vector of one or more modes of travel valid values TRANSIT, WALK, BICYCLE, CAR, BUS, RAIL, SUBWAY, TRAM, FERRY, default CAR. Not all combinations are valid e.g. c("WALK","BUS") is valid but c("WALK","CAR") is not. |
date_time |
POSIXct, a date and time, defaults to current date and time |
maxWalkDistance |
Numeric passed to OTP in metres |
arriveBy |
Logical, Whether the trip should depart or arrive at the specified date and time, default FALSE |
routeOptions |
Named list of values passed to OTP use |
timezone |
Character, what timezone to use, see as.POSIXct, default is local timezone |
ncores |
How many cores to use default = 1 |
THis function requires the analysis and pointset features to be enabled during 'otp_setup()'. Thus it will only work with OTP 1.x. For more detail see the analyst vignette.
Returns a list with information about the surface created
Other analyst:
otp_traveltime()
## Not run: surface <- otp_make_surface(otpcon, c(-1.17502, 50.64590)) ## End(Not run)
## Not run: surface <- otp_make_surface(otpcon, c(-1.17502, 50.64590)) ## End(Not run)
This is the main routing function for OTP and can find single or multiple routes between 'fromPlace' and 'toPlace'.
otp_plan( otpcon = NA, fromPlace = NA, toPlace = NA, fromID = NULL, toID = NULL, mode = "CAR", date_time = Sys.time(), arriveBy = FALSE, maxWalkDistance = 1000, numItineraries = 3, routeOptions = NULL, full_elevation = FALSE, get_geometry = TRUE, ncores = max(round(parallel::detectCores() * 1.25) - 1, 1), timezone = otpcon$timezone, distance_balance = FALSE, get_elevation = FALSE )
otp_plan( otpcon = NA, fromPlace = NA, toPlace = NA, fromID = NULL, toID = NULL, mode = "CAR", date_time = Sys.time(), arriveBy = FALSE, maxWalkDistance = 1000, numItineraries = 3, routeOptions = NULL, full_elevation = FALSE, get_geometry = TRUE, ncores = max(round(parallel::detectCores() * 1.25) - 1, 1), timezone = otpcon$timezone, distance_balance = FALSE, get_elevation = FALSE )
otpcon |
OTP connection object produced by otp_connect() |
fromPlace |
Numeric vector, Longitude/Latitude pair, e.g. 'c(-0.134649,51.529258)', or 2 column matrix of Longitude/Latitude pairs, or sf data frame of POINTS with CRS 4326 |
toPlace |
Numeric vector, Longitude/Latitude pair, e.g. 'c(-0.088780,51.506383)', or 2 column matrix of Longitude/Latitude pairs, or sf data frame of POINTS with CRS 4326 |
fromID |
character vector same length as fromPlace |
toID |
character vector same length as toPlace |
mode |
character vector of one or more modes of travel valid values "TRANSIT","BUS", "RAIL", "SUBWAY","TRAM", "FERRY", "GONDOLA", "FUNICULAR", "AIRPLANE", "CABLE_CAR", "WALK", "BICYCLE", "BICYCLE_RENT", "BICYCLE_PARK", "CAR", "CAR_PARK", "CAR_HAIL", "CARPOOL", "CAR_DROPOFF", "CAR_PICKUP", default "CAR". Not all combinations are valid e.g. c("WALK","BUS") is valid but c("WALK","CAR") is not. |
date_time |
POSIXct, a date and time, defaults to current date and time |
arriveBy |
Logical, Whether the trip should depart or arrive at the specified date and time, default FALSE |
maxWalkDistance |
Numeric passed to OTP in meters |
numItineraries |
The maximum number of possible itineraries to return |
routeOptions |
Named list of values passed to OTP use 'otp_route_options()' to make template object. |
full_elevation |
Logical, should the full elevation profile be returned, default FALSE |
get_geometry |
Logical, should the route geometry be returned, default TRUE, see details |
ncores |
Numeric, number of cores to use when batch processing, default 1, see details |
timezone |
Character, what timezone to use, see as.POSIXct, default is local timezone |
distance_balance |
Logical, use distance balancing, default false, see details |
get_elevation |
Logical, default FALSE, if true XYZ coordinates returned else XY coordinates returned. |
This function returns a SF data.frame with one row for each leg of the journey (a leg is defined by a change in mode). For transit, more than one route option may be returned and is indicated by the 'route_option' column. The number of different itineraries can be set with the 'numItineraries' variable.
## Batch Routing
When passing a matrix or SF data frame object to fromPlace and toPlace 'otp_plan' will route in batch mode. In this case the 'ncores' variable will be used. Increasing 'ncores' will enable multicore routing, the max 'ncores' should be 1.25 times the number of cores on your system. The default is 1.25 timees -1 for improved stability.
## Distance Balancing
When using multicore routing each task does not take the same amount of time. This can result in wasted time between batches. Distance Balancing sorts the routing by the euclidean distance between fromPlace and toPlace before routing. This offers a small performance improvement of around five percent. As the original order of the inputs is lost fromID and toID must be provided.
## Elevation
OTP supports elevation data and can return the elevation profile of the route if available. OTP returns the elevation profile separately from the XY coordinates, this means there is not direct match between the number of XY points and the number of Z points. OTP also only returns the elevation profile for the first leg of the route (this appears to be a bug). If 'get_elevation' is TRUE the otp_plan function matches the elevation profile to the XY coordinates to return an SF linestring with XYZ coordinates. If you require a more detailed elevation profile, the full_elevation parameter will return a nested data.frame with three columns. first and second are returned from OTP, while distance is the cumulative distance along the route and is derived from First.
## Route Geometry
The 'get_geometry' provides the option to not return the route geometry, and just return the meta-data (e.g. journey time). This may be useful when creating an Origin:Destination matrix and also provides a small performance boost by reduced processing of geometries.
Returns an SF data frame of LINESTRINGs
Other routing:
otp_geocode()
,
otp_isochrone()
,
otp_pointset()
,
otp_routing_options()
,
otp_validate_routing_options()
## Not run: otpcon <- otp_connect() otp_plan(otpcon, c(0.1, 55.3), c(0.6, 52.1)) otp_plan(otpcon, c(0.1, 55.3), c(0.6, 52.1), mode = c("WALK", "TRANSIT") ) otp_plan(otpcon, c(0.1, 55.3), c(0.6, 52.1), mode = "BICYCLE", arriveBy = TRUE, date_time = as.POSIXct(strptime("2018-06-03 13:30", "%Y-%m-%d %H:%M")) ) ## End(Not run)
## Not run: otpcon <- otp_connect() otp_plan(otpcon, c(0.1, 55.3), c(0.6, 52.1)) otp_plan(otpcon, c(0.1, 55.3), c(0.6, 52.1), mode = c("WALK", "TRANSIT") ) otp_plan(otpcon, c(0.1, 55.3), c(0.6, 52.1), mode = "BICYCLE", arriveBy = TRUE, date_time = as.POSIXct(strptime("2018-06-03 13:30", "%Y-%m-%d %H:%M")) ) ## End(Not run)
Pointsets are text files tha can be used by the Analyist feature in OTP 1.5
otp_pointset(points = NULL, name = NULL, dir = NULL)
otp_pointset(points = NULL, name = NULL, dir = NULL)
points |
sf data frame of POINTS with CRS 4326 |
name |
Character, name for pointset |
dir |
A character string, path to a directory containing the necessary files, see details |
OTP will return a maximum of 10 results
Returns a data.frame of SF POINTS or Coordinates of all the locations that match 'query'
Other routing:
otp_geocode()
,
otp_isochrone()
,
otp_plan()
,
otp_routing_options()
,
otp_validate_routing_options()
## Not run: locations <- otp_geocode(otpcon, "High Street") ## End(Not run)
## Not run: locations <- otp_geocode(otpcon, "High Street") ## End(Not run)
OTP supports a wide selection of routing options 'otp_plan()' accepts a named list of these options. This function produces an empty named list of valid options supported by both this package and OTP.
otp_routing_options()
otp_routing_options()
Supports almost all of the possible options in OTP 1.4. Note that some of the most popular option (mode, date, time, etc.) are set directly in 'otp_plan()'. If you want to permenaty set an option many are supported in the config files, see help on 'otp_make_config()'.
http://dev.opentripplanner.org/apidoc/1.4.0/resource_PlannerResource.html
Other routing:
otp_geocode()
,
otp_isochrone()
,
otp_plan()
,
otp_pointset()
,
otp_validate_routing_options()
## Not run: routingOptions <- otp_routing_options() routingOptions$walkSpeed <- 1.5 routingOptions <- otp_validate_routing_options(routingOptions) ## End(Not run)
## Not run: routingOptions <- otp_routing_options() routingOptions$walkSpeed <- 1.5 routingOptions <- otp_validate_routing_options(routingOptions) ## End(Not run)
OTP is run in Java and requires Java commands to be typed into the command line. The function allows the parameters to be defined in R and automatically passed to Java. This function sets up a local instance of OTP, for remote versions see documentation.
The function assumes you have run otp_build_graph()
otp_setup( otp = NULL, dir = NULL, memory = 2048, router = "default", port = 8080, securePort = 8081, analyst = FALSE, pointsets = FALSE, wait = TRUE, flag64bit = TRUE, quiet = TRUE, otp_version = NULL, open_browser = TRUE )
otp_setup( otp = NULL, dir = NULL, memory = 2048, router = "default", port = 8080, securePort = 8081, analyst = FALSE, pointsets = FALSE, wait = TRUE, flag64bit = TRUE, quiet = TRUE, otp_version = NULL, open_browser = TRUE )
otp |
A character string, path to the OTP .jar file |
dir |
A character string, path to a directory containing the necessary files, see details |
memory |
A positive integer. Amount of memory to assign to the OTP in MB, default is 2048 |
router |
A character for the name of the router to use, must be subfolder of dir/graphs, default "default". See vignettes for details. |
port |
A positive integer. Optional, default is 8080. |
securePort |
A positive integer. Optional, default is 8081. |
analyst |
Logical. Should the analyst features be loaded? Default FALSE |
pointsets |
Logical. Should the pointsets be loaded? Default FALSE |
wait |
Logical, Should R wait until OTP has loaded before running next line of code, default TRUE |
flag64bit |
Logical, if true the -d64 flag is added to Java instructions, ignored if otp_version >= 2 |
quiet |
Logical, if FALSE the Java commands will be printed to console |
otp_version |
Numeric, version of OTP to build, default NULL when version is auto-detected |
open_browser |
Logical, if TRUE web browser is loaded when OTP is ready |
To run an OTP graph must have been created using otp_build_graph and the following files to be in the directory specified by the dir variable.
/graphs - A sub-directory
/default - A sub-directory with the name of the OTP router used in 'router' variable
graph.obj OTP graph
This function does not return a value to R. If wait is TRUE R will wait until OTP is running (maximum of 5 minutes). After 5 minutes (or if wait is FALSE) the function will return R to your control, but the OTP will keep loading.
Other setup:
otp_build_graph()
,
otp_check_java()
,
otp_check_version()
,
otp_dl_demo()
,
otp_dl_jar()
,
otp_make_config()
,
otp_stop()
,
otp_validate_config()
,
otp_write_config()
## Not run: otp_setup( otp = "C:/otp/otp.jar", dir = "C:/data" ) otp_setup( otp = "C:/otp/otp.jar", dir = "C:/data", memory = 5000, analyst = TRUE ) ## End(Not run)
## Not run: otp_setup( otp = "C:/otp/otp.jar", dir = "C:/data" ) otp_setup( otp = "C:/otp/otp.jar", dir = "C:/data", memory = 5000, analyst = TRUE ) ## End(Not run)
OTP is run in Java and requires Java commands to be typed into the command line. The function allows the parameters to be defined in R and automatically passed to Java. This function stops an already running OTP instance
otp_stop(warn = TRUE, kill_all = TRUE)
otp_stop(warn = TRUE, kill_all = TRUE)
warn |
Logical, should you get a warning message |
kill_all |
Logical, should all Java instances be killed? |
The function assumes you have run otp_setup()
This function return a message but no object
Other setup:
otp_build_graph()
,
otp_check_java()
,
otp_check_version()
,
otp_dl_demo()
,
otp_dl_jar()
,
otp_make_config()
,
otp_setup()
,
otp_validate_config()
,
otp_write_config()
## Not run: otp_stop(kill_all = FALSE) ## End(Not run)
## Not run: otp_stop(kill_all = FALSE) ## End(Not run)
Evaluate a surface created with 'otp_make_surface' against a pointset made with 'otp_pointset' to get travel times and statitics from the analysit in OTP 1.x
otp_surface( otpcon = NULL, surface = NULL, pointsset = NULL, get_data = TRUE, ncores = 1 )
otp_surface( otpcon = NULL, surface = NULL, pointsset = NULL, get_data = TRUE, ncores = 1 )
otpcon |
OTP connection object produced by otp_connect() |
surface |
A surface list from otp_make_surface() |
pointsset |
character, name of pointset |
get_data |
Logical, should data be returned or just travel times. |
ncores |
Integer, number of cores to use |
THis function requires the analysis and pointset features to be enabled during 'otp_setup()'. Thus it will only work with OTP 1.x. For more detail see the analyst vignette.
Returns a list of data.frames of travel times
## Not run: times <- otp_surface(otpcon, c(-1.17502, 50.64590), "lsoa", path_data) ## End(Not run)
## Not run: times <- otp_surface(otpcon, c(-1.17502, 50.64590), "lsoa", path_data) ## End(Not run)
Make a raster image (picture) of travel time using the surface features in OTP 1.x
otp_surface_isochrone(otpcon = NULL, surface = NULL)
otp_surface_isochrone(otpcon = NULL, surface = NULL)
otpcon |
OTP connection object produced by otp_connect() |
surface |
A surface list from otp_make_surface() |
THis function requires the analysis and pointset features to be enabled during 'otp_setup()'. Thus it will only work with OTP 1.x. For more detail see the analyst vignette.
Returns a data.frame of travel times
## Not run: times <- otp_surface(otpcon, c(-1.17502, 50.64590), "lsoa", path_data) ## End(Not run)
## Not run: times <- otp_surface(otpcon, c(-1.17502, 50.64590), "lsoa", path_data) ## End(Not run)
This function requires OTP 1.x and the analyst
otp_traveltime( otpcon = NA, path_data = NULL, fromPlace = NA, toPlace = NA, fromID = NULL, toID = NULL, mode = "CAR", date_time = Sys.time(), arriveBy = FALSE, maxWalkDistance = 1000, numItineraries = 3, routeOptions = NULL, ncores = max(round(parallel::detectCores() * 1.25) - 1, 1), timezone = otpcon$timezone )
otp_traveltime( otpcon = NA, path_data = NULL, fromPlace = NA, toPlace = NA, fromID = NULL, toID = NULL, mode = "CAR", date_time = Sys.time(), arriveBy = FALSE, maxWalkDistance = 1000, numItineraries = 3, routeOptions = NULL, ncores = max(round(parallel::detectCores() * 1.25) - 1, 1), timezone = otpcon$timezone )
otpcon |
OTP connection object produced by otp_connect() |
path_data |
Path to data used in otp_build_graph() |
fromPlace |
Numeric vector, Longitude/Latitude pair, e.g. 'c(-0.134649,51.529258)', or 2 column matrix of Longitude/Latitude pairs, or sf data frame of POINTS with CRS 4326 |
toPlace |
Numeric vector, Longitude/Latitude pair, e.g. 'c(-0.088780,51.506383)', or 2 column matrix of Longitude/Latitude pairs, or sf data frame of POINTS with CRS 4326 |
fromID |
character vector same length as fromPlace |
toID |
character vector same length as toPlace |
mode |
character vector of one or more modes of travel valid values TRANSIT, WALK, BICYCLE, CAR, BUS, RAIL, default CAR. Not all combinations are valid e.g. c("WALK","BUS") is valid but c("WALK","CAR") is not. |
date_time |
POSIXct, a date and time, defaults to current date and time |
arriveBy |
Logical, Whether the trip should depart or arrive at the specified date and time, default FALSE |
maxWalkDistance |
Numeric passed to OTP in metres |
numItineraries |
The maximum number of possible itineraries to return |
routeOptions |
Named list of values passed to OTP use 'otp_route_options()' to make template object. |
ncores |
Numeric, number of cores to use when batch processing, default 1, see details |
timezone |
Character, what timezone to use, see as.POSIXct, default is local timezone |
Make a travel time matrix using the analyst features in OPT 1.x
Returns an data frame
Other analyst:
otp_make_surface()
Checks if the list of OTP configuration options is valid
otp_validate_config(config, type = attributes(config)$config_type, version = 1)
otp_validate_config(config, type = attributes(config)$config_type, version = 1)
config |
A named list made/modified from 'otp_make_config()' |
type |
type of config file |
version |
version of OPT e.g. 1 or 2 |
Performs basic validity checks on class, max/min values etc as appropriate, some of more complex parameters are not checked. For more details see:
http://docs.opentripplanner.org/en/latest/Configuration http://dev.opentripplanner.org/javadoc/1.3.0/org/opentripplanner/routing/core/RoutingRequest.html
Other setup:
otp_build_graph()
,
otp_check_java()
,
otp_check_version()
,
otp_dl_demo()
,
otp_dl_jar()
,
otp_make_config()
,
otp_setup()
,
otp_stop()
,
otp_write_config()
## Not run: conf <- otp_make_config("build") otp_validate_config(conf) ## End(Not run)
## Not run: conf <- otp_make_config("build") otp_validate_config(conf) ## End(Not run)
OTP supports a wide selection of routing options 'otp_plan()' accepts a named list of these options. This function validates a named list of inputs and removes any empty inputs.
otp_validate_routing_options(opts)
otp_validate_routing_options(opts)
opts |
a named list of options possibly from 'otp_routing_options()' |
Supports almost all of the possible options in OTP 1.4. Note that some of the most popular option (mode, date, time, etc.) are set directly in 'otp_plan()'. If you want to permenaty set an option many are supported in the config files, see help on 'otp_make_config()'. http://dev.opentripplanner.org/apidoc/1.4.0/resource_PlannerResource.html
Other routing:
otp_geocode()
,
otp_isochrone()
,
otp_plan()
,
otp_pointset()
,
otp_routing_options()
## Not run: routingOptions <- otp_routing_options() routingOptions$walkSpeed <- 1.5 routingOptions <- otp_validate_routing_options(routingOptions) ## End(Not run)
## Not run: routingOptions <- otp_routing_options() routingOptions$walkSpeed <- 1.5 routingOptions <- otp_validate_routing_options(routingOptions) ## End(Not run)
Takes a config list produced by 'otp_make_config()' and saves it as json file for OTP
otp_write_config(config, dir = NULL, router = "default")
otp_write_config(config, dir = NULL, router = "default")
config |
A named list made/modified from 'otp_make_config()' |
dir |
Path to folder where data for OTP is to be stored |
router |
name of the router, default is "default", must be a subfolder of dir/graphs |
Other setup:
otp_build_graph()
,
otp_check_java()
,
otp_check_version()
,
otp_dl_demo()
,
otp_dl_jar()
,
otp_make_config()
,
otp_setup()
,
otp_stop()
,
otp_validate_config()
## Not run: conf <- otp_make_config("build") otp_write_config(conf, dir = tempdir()) ## End(Not run)
## Not run: conf <- otp_make_config("build") otp_write_config(conf, dir = tempdir()) ## End(Not run)