Movatterモバイル変換


[0]ホーム

URL:


Public Transit API

Request public transport connections between given points and findstations nearby using the ‘HERE Public Transit’ API.

Connections

The functionconnection() allows to request publictransport connections from the API. Two types of requests areprovided:

1. Sections

Request available public transport connections as detailedsections:

connection_section<-connection(origin = poi[3:4, ],destination = poi[5:6, ],summary =FALSE)

Theid column corresponds to the row of the inputlocations (origin anddestination) and therank column enumerates the alternative routes. The maximumnumber of alternatives can be set by theresults parameter.Each row in the returnedsf object corresponds to a routesection with a transport mode in a vehicle without a transfer.

idranksectiondepartureoriginarrivaldestinationmodecategoryvehicleproviderdirectiondistanceduration
1112023-09-18 14:48:00ORIG2023-09-18 14:52:00Lausanne, VallonnettepedestrianNANANANA211240
1122023-09-18 14:52:00Lausanne, Vallonnette2023-09-18 15:01:00Lausanne, St-FrançoisbusBus Service6Transports Publics de la Région Lausannoise saLausanne, Montoie3218540
1132023-09-18 15:03:00Lausanne, St-François2023-09-18 15:07:00Lausanne, CloseletbusBus Service2Transports Publics de la Région Lausannoise saLausanne, Maladière-Lac1003240
1142023-09-18 15:07:00Lausanne, Closelet2023-09-18 15:12:00LausannepedestrianNANANANA300300
1152023-09-18 15:13:00Lausanne2023-09-18 16:27:00BernintercityTrainLong Distance TrainsIC1Schweizerische Bundesbahnen SBBSt. Gallen970304440
1162023-09-18 16:32:00Bern2023-09-18 16:43:00Kehrsatz NordcityTrainSuburban RailwayS3BLS AG (bls)Belp8686660

Print the public transport sections on an interactive leafletmap:

if (requireNamespace("mapview",quietly =TRUE)) {  mapview::mapview(connection_section,zcol ="mode",layer.name ="Transport mode",map.types =c("Esri.WorldTopoMap"),homebutton =FALSE  )}

2. Summary

Request a summary of the available public transport connections:

connection_summary<-connection(origin = poi[3:4, ],destination = poi[5:6, ],summary =TRUE)
idrankdepartureoriginarrivaldestinationtransfersmodescategoriesvehiclesprovidersdistanceduration
112023-09-18 14:48:00Lausanne, Vallonnette2023-09-18 16:46:00Kehrsatz Nord3pedestrian, bus, bus, pedestrian, intercityTrain, cityTrain, pedestrianBus Service, Bus Service, Long Distance Trains, Suburban Railway6, 2, IC1, S3Transports Publics de la Région Lausannoise sa, Transports Publics de laRégion Lausannoise sa, Schweizerische Bundesbahnen SBB, BLS AG (bls)1106516600
122023-09-18 14:54:00Lausanne, Georgette2023-09-18 17:40:00Wabern, Kleinwabern3pedestrian, bus, pedestrian, intercityTrain, cityTrain, pedestrian, bus,pedestrianBus Service, Inter Regional Rail Service, Suburban Railway, Bus Service1, IR15, S3, 22Transports Publics de la Région Lausannoise sa, SchweizerischeBundesbahnen SBB, BLS AG (bls), Städtische Verkehrsbetriebe Bern1091169180
212023-09-18 15:00:00Kleinhüningen2023-09-18 16:41:00Zürich HB1pedestrian, lightRail, pedestrian, highSpeedTrain, pedestrianTram Service, High Speed Rail Service8, TGV TGVBasler Verkehrsbetriebe, Schweizerische Bundesbahnen SBB970065880
222023-09-18 15:02:00Kleinhüningen2023-09-18 16:41:00Zürich HB2pedestrian, bus, pedestrian, cityTrain, highSpeedTrain, pedestrianBus Service, Suburban Railway, High Speed Rail Service46, S6, TGV TGVBasler Verkehrsbetriebe, SBB GmbH (Grenzverkehr), SchweizerischeBundesbahnen SBB968965460

Stations

The functionstation() allows to request publictransport stations nearby points of interest (POIs). Theradius defines the maximum search distance in meters andresults specifies the maximum number of returned stations.The returnedsf object contains the locations of thestations and the available public transport lines at the station.

stations<-station(poi = poi,radius =500,results =5)

Print the POIs, the radius and stations on an interactive leafletmap:

buffer<-  poi%>%st_transform(2056)%>%st_buffer(500)%>%st_transform(4326)if (requireNamespace("mapview",quietly =TRUE)) {  m<-    mapview::mapview(poi,alpha.region =1,col.region ="black",label = poi$city,layer.name ="POIs",map.types =c("Esri.WorldTopoMap"),homebutton =FALSE    )+    mapview::mapview(stations,col.region ="yellow",alpha =1,label = stations$station,layer.name ="Stations",homebutton =FALSE    )+    mapview::mapview(buffer,col.region ="transparent",alpha.region =0,layer.name ="Buffer",homebutton =FALSE,legend =FALSE    )  m}

API Reference


[8]ページ先頭

©2009-2025 Movatter.jp