gpt4 book ai didi

使用 R 读取 GTFS 实时文件?

转载 作者:行者123 更新时间:2023-12-01 23:40:36 25 4
gpt4 key购买 nike

我想使用 R 分析 GTFS 实时文件,与静态 GTFS 相比,这些文件被编译并且读取它们更棘手。

谷歌搜索,我只找到这个包来处理 GTFS
https://github.com/ropenscilabs/gtfsr

但同样,这仅适用于静态 GTFS。

你知道处理 GTFS-realtime 的 cran/github R 包吗?

另一种解决方案是将 GTFS-RT 转换为更易读的格式,如 json
streaming gtfs real time data into human readable format

最佳答案

我注意到你已经找到了我的 development package, gtfsway .特别是issue 1中的例子举例说明包的工作原理以及它解析实时提要的方式

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

如果您有任何意见,我愿意接受有关该软件包的贡献和建议。

关于使用 R 读取 GTFS 实时文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42132693/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com