Skip to content

A real area from open data

This tutorial assembles every cascade input for a strip of central Napa, California from open data and runs the whole chain on a scenario on a mapped fault. The script is examples/02_open_data.py:

pip install "quakecascade[demo,raster]"
python examples/02_open_data.py

It needs a network connection. If the main Overpass server is busy, point osmnx at a mirror:

OVERPASS_URL="https://maps.mail.ru/osm/tools/overpass/api" python examples/02_open_data.py

Assumptions, not exposure

Open data do not say what a building is made of, how many people live in it or how wide a street is. The script gathers every such value in one ASSUMPTIONS block. They are choices of the example, not package defaults, and the numbers it prints describe those choices, not the real exposure of the area. Replace them with local inventories before reading anything into the result.

1. Download

osm = datasets.fetch_osm(bbox=BBOX)               # buildings, roads, hospitals, fire stations, parks
utm = qcrs.estimate_utm_crs(lon0, lat0)           # the run CRS: a metric UTM zone

fetch_osm returns GeoDataFrames in EPSG:4326. Everything is projected to the local UTM zone before anything is measured, because the package refuses geographic coordinates.

2. Buildings

OpenStreetMap gives footprints and, for some buildings, a building:levels or height tag. The script fills the gaps from the assumptions, and the assumptions are marked as such:

Column From Assumption when missing
floors building:levels, else height / storey height floors_without_tag
height_m height tag floors × storey_height_m
building_type (not in OSM) building_type for every building
occupancy impact.occupancy_class(building tag) unknown_occupancy for building=yes
occupants footprint × floors / area_per_occupant_m2 —
dwelling_units occupants / persons_per_dwelling (residential only) —
vs30_m_s slope of the Copernicus DEM, USGS method —

Vs30 comes from terrain slope, as in the USGS global Vs30 map. The DEM is block-averaged to about 30 arc-seconds, the scale at which the slope–Vs30 bins were derived, and the slope is converted with liquefaction.vs30_from_slope_array(slope, "active").

3. Roads, facilities, planning units

  • Roads. The OSM drive network from osmnx, with road_class taken from the highway tag and width_m from debris.highway_width_m and a width table in ASSUMPTIONS. The package ships no width table, because street widths are a local design standard.
  • Hospitals and fire stations. OSM points or polygons, reduced to a representative point. Hospital beds come from the OSM beds tag where present. Otherwise they stay unknown, and the 2SFCA access of the units that reach that hospital reads partial.
  • Candidate depot sites. OSM parks, with their area.
  • Planning units. 400 m cells. Their population is the sum of the building occupants.

4. Fault and scenario

faults = datasets.fetch_gem_faults(bbox_around_area)
record = faults[faults["catalog_id"] == FAULT_ID].iloc[0]
fault = datasets.gem_fault_geometry(record)       # dip, dip direction, depths, with their source
magnitude = gm.wells_coppersmith_magnitude_from_length(length_km, mechanism)

The scenario fault is a GEM record whose dip, dip direction and seismogenic depths are all given. For a record that lacks one, gem_fault_geometry asks for the value instead of guessing it. Only about one GEM record in eight has all four. The magnitude follows from the mapped length through Wells & Coppersmith (1994).

5. Terrain for liquefaction

New in 0.2.0

grid, grid_transform = datasets.regrid_dem(dem, prof["transform"], prof["crs"], utm, 1000.0)

The same DEM is averaged onto a 1 km grid in the run CRS, the input scale of the Zhu et al. (2015) model. The cascade computes the compound topographic index from it on the HYDRO1k scale the model was fitted on.

6. Run and read

inputs = cascade.CascadeInputs(crs=utm, fault_trace=trace, fault=fault, buildings=buildings,
                               roads=roads, hospitals=..., fire_stations=..., sites=sites,
                               units=units, dem=grid, dem_transform=grid_transform)
res = cascade.run(inputs, cascade.CascadeParams(magnitude=magnitude, mechanism=mechanism,
                                                **PARAMS))

A run of this kind printed (in November 2026, with that day's OpenStreetMap data):

scenario: Hunting Creek - Berryessa 2011 CFM, Mw 7.0 (SS), 44.4 km; ...
buildings                            2691
closed_edges                         0
...
isolation_status  n_units   population
            same       41      20438.0
     no_pre_time        5        174.1

Five planning units lie farther than max_snap_m from the road graph that was downloaded for the area. They have no travel time before the event, and the isolation table counts them as no_pre_time instead of placing them in a category.

Where to go from here

  • Replace each entry of ASSUMPTIONS with local data: a building inventory with structural types and occupants, measured street widths, hospital capacities. See Run on your own inventory.
  • Bracket the choices that remain uncertain, as in Bracket uncertain choices.