Compute modes
The client exposes three ways to compute a human crash-rate baseline. All three run on the same engine and return a rate (per million miles) with a 95% confidence interval, but they differ in geometry and exposure.
Geofence: hb.compute(...)
A county-wide rate, aggregated over Google S2 cells. This is the default mode and is available for every region.
- Numerator: weighted crashes matching your filters.
- Denominator: calibrated vehicle-miles travelled (VMT) across the county.
- Breakdown:
result.cells(one entry per S2 cell) for map rendering.
hb.compute(county="travis", ego_vehicle=["cars", "light_trucks"],
road_type=["arterial", "collector_local"])Use it for: "what is the human crash rate for cars + light trucks on surface streets in Travis County?" → compute reference
Route: hb.compute_route(...)
A rate over an ordered sequence of interstate (route, milepost) segments. Available for the interstate-corridor regions (see Regions).
- Input:
segment_ids, e.g.[("I-35", 250), ("I-35", 251)]. - Denominator: per-segment combination-truck VMT.
- Breakdown:
result.segmentswith per-milepost counts and lengths.
hb.compute_route(segment_ids=[("I-35", 250), ("I-35", 251)],
ego_vehicle=["combination"])Use it for: "what is the crash rate along this stretch of I-35 for combination trucks?" → compute_route reference
Depot: hb.compute_depot_route(...)
A full depot-to-depot trip rate. You give two pins; the engine snaps each to its nearest access cell, picks an on-ramp, routes the interstate leg, and returns a three-leg breakdown (access_a, interstate, access_b) plus a total.
- Input:
depot_aanddepot_bas(lat, lon)tuples (or dicts/DepotPin). - Breakdown: per-leg metrics plus access-cell polygons for rendering.
- A pin farther than the snap limit from a known access cell raises a
400.
hb.compute_depot_route(depot_a=(30.25, -97.75), depot_b=(30.40, -97.70))Use it for: "what is the end-to-end crash rate for a truck running from this warehouse to that one?" → compute_depot_route reference
Choosing a mode
| You have… | Use |
|---|---|
| A county and a set of filters | compute |
| Specific interstate mileposts | compute_route |
| Two endpoints (lat/lon) for a trip | compute_depot_route |
Mode availability per region is enforced server-side: requesting route/depot for a geofence-only county raises a 400. Always check hb.regions().