Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gtfs2gps function issue #221

Closed
Joaobazzo opened this issue Dec 8, 2021 · 1 comment
Closed

gtfs2gps function issue #221

Joaobazzo opened this issue Dec 8, 2021 · 1 comment
Assignees

Comments

@Joaobazzo
Copy link
Collaborator

Looks like the gtfs2gps function are having troubles to check the valid numbers of gtfs$stop_times

> sp_gtfs <- gtfsio::import_gtfs(path = "data/gtfs_spo_sptrans_2019-10_fixed_subway.zip")
> sp_gps <- gtfs2gps::filter_by_shape_id(sp_gtfs,"51007") %>% gtfs2gps::gtfs2gps()
# Converting shapes to sf objects
# Processing the data
# Trip '917H-10-0' has less than two stop_ids. Ignoring it.
# Shape '51007' has no departure_time. Ignoring it.
# 0 out of 1 shapes (0%) were properly processed.
# 0 out of 1 trips (0%) were properly processed.
# Warning messages:
# 1: In eval(jsub, SDenv, parent.frame()) : NAs introduced by coercion
# 2: In eval(jsub, SDenv, parent.frame()) : NAs introduced by coercion
# 3: In eval(jsub, SDenv, parent.frame()) : NAs introduced by coercion
# 4: In eval(jsub, SDenv, parent.frame()) : NAs introduced by coercion

however, when I check the sp_gtfs$stop_times, it looks like the data is fine

> sp_gtfs$stop_times[trip_id == '917H-10-0'] %>% head()
#     trip_id arrival_time departure_time   stop_id stop_sequence
# 1: 917H-10-0     17:00:00       17:00:00 640000518             1
# 2: 917H-10-0     17:02:00       17:02:00 640000359             2
# 3: 917H-10-0     17:04:00       17:04:00   6415325             3
# 4: 917H-10-0     17:06:00       17:06:00   6413868             4
# 5: 917H-10-0     17:08:00       17:08:00 640000224             5
# 6: 917H-10-0     17:10:00       17:10:00 640000172             6
> sp_gtfs$stop_times[trip_id == '917H-10-0'] %>% dim()
# [1] 65  5
@Joaobazzo Joaobazzo self-assigned this Dec 8, 2021
@rafapereirabr
Copy link
Member

I believe this problem is caused because you are using gtfsio::import_gtfs() to read the GTFS file. If you use gtfs2gps::read_gtfs() it should work. This is because our read_gtfs() does a few transformations on the GTFS feed that are not present in import_gtfs()

sp_gtfs <- gtfs2gps::read_gtfs(path = "data/gtfs_spo_sptrans_2019-10_fixed_subway.zip")
sp_gps <- gtfs2gps::filter_by_shape_id(sp_gtfs,"51007") %>% gtfs2gps::gtfs2gps()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants