问题描述
我想使用R分析GTFS实时文件,与静态GTFS相比,这些文件是经过编译的,读取起来比较棘手.
I want to analyze GTFS-realtime files using R, compared to the static GTFS, these files are compiled and reading them is trickier.
谷歌搜索,我只发现该软件包可以处理GTFS https://github.com/ropenscilabs/gtfsr
Googling around, I have only found this package to deal with GTFShttps://github.com/ropenscilabs/gtfsr
但同样,这仅适用于静态GTFS.
But again, this is just for static GTFS.
您是否知道可以实时处理GTFS的cran/github R软件包?
Are you aware of a cran/github R package that deals with GTFS-realtime?
另一种解决方案是将GTFS-RT转换为更具可读性的格式,例如json将gtfs实时数据流化为人类可读格式
An alternative solution would be to convert the GTFS-RT into a more readable format like jsonstreaming gtfs real time data into human readable format
推荐答案
我注意到您已经找到了进入我的开发包gtfsway .特别是,问题1 中的示例提供了该程序包如何工作的示例以及解析实时供稿的方式
I notice you already found your way over to my development package, gtfsway. In particular, the example in issue 1 gives an example of how the package works and the way it parses a realtime feed
devtools::install_github("SymbolixAU/gtfsway")
library(gtfsway)
url <- "https://gtfsrt.api.translink.com.au/Feed/SEQ"
response <- httr::GET(url)
FeedMessage <- gtfs_realtime(response)
## the function gtfs_tripUpdates() extracts the 'trip_update' feed
lst <- gtfs_tripUpdates(FeedMessage)
## The results will obviously change depending on when you read the data
lst[[32]]
# $dt_trip_info
# trip_id start_time start_date route_id
# 1: 8959814-SBL 16_17-SBL_FUL-Friday-04 12:21:00 20170303 709-739
#
# $dt_stop_time_update
# stop_sequence stop_id arrival_time arrival_delay departure_time departure_delay
# 1: 1 318944 1488504104 -3556 1488507660 0
# 2: 2 318946 1488507741 21 1488507741 21
# 3: 3 300444 1488507903 3 1488507903 3
# 4: 4 300058 1488507977 17 1488507977 17
# 5: 5 300059 1488508022 2 1488508022 2
# 6: 6 300060 1488508094 -46 1488508094 -46
# 7: 7 300061 1488508115 -25 1488508115 -25
# 8: 8 300062 1488508148 -52 1488508148 -52
# 9: 9 300063 1488508175 -85 1488508175 -85
# 10: 10 300005 1488508299 -141 1488508299 -141
# 11: 11 300053 1488508398 -102 1488508398 -102
# 12: 12 300054 1488508458 -102 1488508458 -102
# 13: 13 300056 1488508638 -102 1488508638 -102
# 14: 14 300055 1488508758 -102 1488508758 -102
# 15: 15 300272 1488508998 -102 1488508998 -102
# 16: 16 319160 1488509058 -102 1488509058 -102
我愿意接受捐款&包装上的建议(如果有).
I'm open to contributions & suggestions on the package if you have any.
这篇关于使用R读取GTFS实时文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!