Skip to content

Compute modes

The client offers 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. They differ in geometry and exposure.

Geofence: hb.compute(...)

A region-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 region.
  • Breakdown: result.cells, one entry per S2 cell, for map rendering.
python
hb.compute(region="travis", ego_vehicle=["cars", "light_trucks"],
           road_type=["arterial", "collector_local"])

Use this for a question about a region and a filter set, such as the crash rate for cars and light trucks on surface streets in Travis County. See the 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.segments, with per-milepost counts and lengths.
python
hb.compute_route(segment_ids=[("I-35", 250), ("I-35", 251)],
                 ego_vehicle=["combination"])

Use this for a question about a specific stretch of interstate, such as the combination-truck rate along a run of I-35. See the compute_route reference.

Depot: hb.compute_depot_route(...)

A full depot-to-depot trip rate. You give two pins, and 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_a and depot_b as (lat, lon) tuples, or dicts, or 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.
python
hb.compute_depot_route(depot_a=(30.25, -97.75), depot_b=(30.40, -97.70))

Use this for an end-to-end trip between two points, such as a truck running from one warehouse to another. See the compute_depot_route reference.

Choosing a mode

You have…Use
A region and a set of filterscompute
Specific interstate milepostscompute_route
Two endpoints (lat/lon) for a tripcompute_depot_route

Mode availability per region is enforced server-side: requesting route or depot for a geofence-only region raises a 400. Check hb.regions() first.

Derived statistics only. Attribute every published figure. Maintained by Valgo.