Replies: 3 comments
-
Great idea @mpadge! Some thoughts that came up when reading your post:
Edit:
Edit2: And btw, I think |
Beta Was this translation helpful? Give feedback.
-
Hi all. This is a really tricky problem we've also faced with the
Here is the code. This is a solution tailored to our need of calculating speeds between stops, but I would be glad to hear how the others have been addressing the midnight trips problem. |
Beta Was this translation helpful? Give feedback.
-
For my use cases it wasn't necessary to normalize times and I think it might introduce more problems than it might solve. A standard "public transit day" starts/ends at ~3am so there's always some overlap. tidytransit's set_hms_times converts times to hms/difftime objects which are basically a time in seconds. They're not limited to a 0-24h range, so values after midnight are just >84600 (see hhmmss_to_seconds). This allows for simple calculations (no need to check for negative values) and ggplot handles hms scales quite nicely, as you can see in the timetable vignette. However, for calculations the date specified refers to the "pt day" a trip belongs to rather than the actual date it happens. That's not really an issue though as trips after midnight are generally not that important and they "belong" to the previous day anyways, in Switzerland at least. |
Beta Was this translation helpful? Give feedback.
-
@dhersz There are no GTFS standards for how
stop_times.txt
should represent trips starting before and after midnight, other than to "enter a value greater than 24:00:00 for trips starting after midnight". I often need to "regularize" astop_times
table by converting all entries to havedeparture_time
entries between 0 and 23:59:59. Among other reasons, this is important to extract statistics on actual trip frequencies and the like, which are best standardized to estimates within a single 24 hour period.Another reason this is important is because systems which effectively run round the clock must nevertheless cut their
stop_times
somewhere to give a representation within their GTFS feed of a single "day". These kinds of feeds often repeat trips early in the morning at the ends of feeds (with times > 24:00:00), so contain redundancies which must be removed for accurate statistical analyses.A
stop_times
regularization function would perform the two simple steps of:Do you think that
gtfstools
would be a good home for a routine like that? If so, I could easily open an issue there, an help get the routine together.Thoughts @polettif @rafapereirabr @tbuckl ?
Beta Was this translation helpful? Give feedback.
All reactions