Congestion tti#1383
Conversation
…ison table dynamic
ShahrzadBorjian2
left a comment
There was a problem hiding this comment.
Thanks @gabrielwol. Looks great. I have added my comments.
| @@ -0,0 +1,52 @@ | |||
| CREATE OR REPLACE FUNCTION here_agg.agg_overnight_tt( | |||
There was a problem hiding this comment.
Would you add some high level comments?
| FROM here_agg.raw_segments | ||
| WHERE | ||
| dt >= agg_overnight_tt.mnth - interval '6 months' | ||
| AND dt < agg_overnight_tt.mnth |
There was a problem hiding this comment.
I thought we decided to use force mnth to month rolling instead of day to day
| SELECT | ||
| segment_id, | ||
| agg_overnight_tt.mnth AS mnth, | ||
| AVG(tt) AS overnight_avg_tt, |
There was a problem hiding this comment.
I used weighted average travel time (by obs) not sure if we want to use that approach.
| ) OR ( | ||
| dt >= '2024-01-01'::date | ||
| AND hr BETWEEN 1 AND 4 | ||
| ) |
There was a problem hiding this comment.
We need to re-run analysis each year to select minim 4 hr time window
There was a problem hiding this comment.
That's not an easy thing to operationalize into an automated pipeline, I would suggest omitting it going forward.
|
|
||
| INSERT INTO here_agg.segment_overnight_tts ( | ||
| segment_id, mnth, overnight_avg_tt, rolling_6month_quasi_obs | ||
| ) |
There was a problem hiding this comment.
Should we add minimum observation threshold?
| cc.area_name | ||
| FROM congestion.congestion_segments AS seg | ||
| JOIN gis.community_council_2018 AS cc | ||
| ON cc.the_geom && seg.geom --quick bounding box intersection using gist idx |
There was a problem hiding this comment.
So the function may assign a segment to a community council just because their boxes overlap, even if the real geometries do not?
There was a problem hiding this comment.
Good catch, I was missing an st_intersects in the where clause. Usually using a && join along with an st_intersects is faster than simply joining on st_intersects.
| ON st_intersects(st_transform(dt.geom, 4326), seg.geom) | ||
| WHERE seg.ver_id = here_agg.select_map_version( | ||
| start_date := segment_areas.mnth, | ||
| end_date := segment_areas.mnth + 1, |
There was a problem hiding this comment.
You meant one day interval not one month, right?
There was a problem hiding this comment.
1 day is OK, because map version should be the same for entire month.
adding that as a comment.
| 'Downtown' AS area_name | ||
| FROM congestion.congestion_segments AS seg | ||
| JOIN gis.to_core_downtown AS dt | ||
| ON st_intersects(st_transform(dt.geom, 4326), seg.geom) |
There was a problem hiding this comment.
So we want any intersect with "downtown" to be considered as "downtown" ?
| @@ -0,0 +1,22 @@ | |||
| -- Table: here_agg.monthly_link_vkt | |||
There was a problem hiding this comment.
same as above, the naming might be confusing as thereis no vkt yet
There was a problem hiding this comment.
Renaming to monthly_link_sample_size 👍
| | hr | smallint | 0 | | | ||
| | tti | double precision | 1.0812660631815794 | | | ||
| | num_segments | integer | 4777 | | | ||
| | road_category | text | Non-Highway | | |
There was a problem hiding this comment.
A few minor comments:
- Clarify that the 6-month rolling is based on monthly aggregates, not daily data
- Note that monthly_link_vkt stores sample_size (not true VKT), VKT is calculated later as sample_size * length
- Add a simple pipeline/data flow diagram to connect tables
- Clarify that overnight TT = free-flow baseline (used for TTI denominator)
- Simplify explanation of num_obs is “approx number of vehicles from probe data”
- Check segment_id type consistency (integer vs bigint)
- In area_tti, clarify that TTI is VKT-weighted hourly TTI
- mention that 6-month rolling aligns with overnight baseline methodology
…solve map version issues



What this pull request accomplishes:
Implementing new segment level and aggregated tti using updated tti methodology
Issue(s) this solves:
What, in particular, needs to reviewed:
What needs to be done by a sysadmin after this PR is merged
_create new functions to produce tti values