-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
Milestone
Description
The docs say:
Approach level bicycle counts should be used for the large majority of applications as the data is considered more accurate.
However, for most intersection-approach combinations, bike entrances (classification_uid = 10 AND movement_uid = 7), are fewer in number than bike tmc (classification_uid = 2):
| "category" | "approach_count" | "distinct_intersection_count" |
|---|---|---|
| "bike_entrances < bike_tmc" | 175 | 52 |
| "bike_entrances >= bike_tmc" | 13 | 10 |
| "bike_entrances IS NULL AND bike_tmc IS NOT NULL" | 30 | 11 |
| "bike_tmc IS NULL" | 13 | 9 |
SQL used below. Can remove the last aggregation to see individual intersection/approach combos.
WITH bike_summary AS (
SELECT
intersection_uid,
leg AS approach,
SUM(volume) FILTER (WHERE classification_uid = 2) AS bike_tmc,
SUM(volume) FILTER (WHERE classification_uid = 10 AND movement_uid = 7) AS bike_entrances
FROM miovision_api.volumes
WHERE
datetime_bin >= '2023-12-01'::date
AND datetime_bin < '2023-12-12'::date
GROUP BY
intersection_uid,
leg
),
categories AS (
SELECT
intersection_uid,
approach,
CASE
WHEN bike_entrances < bike_tmc THEN 'bike_entrances < bike_tmc'
WHEN bike_entrances IS NULL AND bike_tmc IS NOT NULL THEN 'bike_entrances IS NULL AND bike_tmc IS NOT NULL'
WHEN bike_tmc IS NULL THEN 'bike_tmc IS NULL'
WHEN bike_entrances >= bike_tmc THEN 'bike_entrances >= bike_tmc'
END AS category,
bike_entrances,
bike_tmc
FROM bike_summary
)
SELECT
category,
COUNT(*) AS approach_count,
COUNT(DISTINCT intersection_uid) AS distinct_intersection_count
FROM categories
GROUP BY category