Skip to main content
← All writingKylan Thomson

Simulation · Geospatial Data

Live Data for a Wildfire Simulator: ERA5 Weather and OpenStreetMap Buildings

Pick a point and a date range, and the simulator builds that place from open data in a few seconds. This is the data layer: what each source provides, how it is rasterised, and what happens when one of them is down.

Published
Reading time
10 minutes
Project
Wildfire Sentinel case study

Pick any point on Earth and any date range since 1940, and Wildfire Sentinel builds a working simulation of that place in a few seconds: elevation from terrain tiles, building footprints and critical facilities from OpenStreetMap, water bodies, hourly reanalysis weather, and, for a real fire, the perimeter that was actually recorded. No API keys, no server, no bundled fixtures. This is how that data layer works, source by source, and what it does when a source is down.

The decision to fetch live rather than ship a canned dataset is the one that makes the tool an instrument instead of a demo of one fire. It also means living inside other people's rate limits and CORS policies, in the browser, with no proxy to hide behind. Most of the engineering in this layer is about that constraint.

One grid to rasterise onto

A scenario is a centre point, a radius, and a date range. The radius becomes a bounding box; the box becomes a grid of 110 columns with rows derived so cells are square. For the default Palisades scenario, an 8-kilometre radius gives a 16-kilometre box, 145-metre cells, and 12,100 cells covering 256 square kilometres. Every source below is sampled or rasterised onto that grid, and the fire engine never sees anything else.

Every layer, its primary source, and what happens when it fails
LayerPrimary sourceFallback
ElevationAWS Terrain Tiles (Terrarium PNG, ~30 m)Open-Meteo elevation API (Copernicus 90 m)
WaterOpenStreetMap water polygons via OverpassSea level only (elevation ≤ 0.5 m)
BuildingsOpenStreetMap building centroids, 4 quadrants in parallel across mirrorsLand-use polygons at 6 structures per cell
Critical facilitiesOpenStreetMap amenity and power tagsNone; failure is non-fatal
WeatherOpen-Meteo ERA5 archive, hourly, 1940 to five days agoBundled METAR fixtures
Observed perimeterNIFC WFIGS ArcGIS feature serviceReported as unavailable
Every layer the simulator needs, where it comes from, and what happens when the primary source fails. Each request is bound to an abort signal tied to the scenario load, so a superseded load cancels everything it started.

Elevation: decode the tiles yourself

Terrain comes from the public terrain-tile bucket in the Terrarium encoding, where each pixel's red, green, and blue channels encode elevation as a 24-bit number offset by 32,768 metres. The loader picks the zoom whose pixel size is finer than a quarter of a cell, fetches every tile covering the box in parallel (capped at 64), draws each onto a canvas to read the pixels, and samples elevation at each cell centre with bilinear interpolation across tile boundaries. If the tiles fail, the fallback is a point-elevation API batched a hundred points per request, which is slower but keyless.

const decodeTerrarium = (r, g, b) => r * 256 + g + b / 256 - 32768;

const pickZoom = (cellSizeM, midLat) => {
  for (let z = 14; z >= 6; z--) {
    const metersPerPx = (156543.03392 * Math.cos((midLat * Math.PI) / 180)) / 2 ** z;
    if (metersPerPx >= cellSizeM / 4) return z;
  }
  return 6;
};
terrainService.js: the whole Terrarium decoding is one line, and the zoom choice is one loop.

The elevation grid drives two things: the slope term in the spread model (upslope fire runs faster, by Rothermel's slope coefficient, capped) and the hillshade the map is drawn with, which is baked once at load from a fixed sun position and normalised between the second and 98th percentile of land cells so both a coastal plain and a mountain range get contrast.

Buildings and water: OpenStreetMap through Overpass

Structures are the thing the simulation is scored on, so they are the layer the loader works hardest for. The bounding box is split into four quadrants fetched in parallel, each starting on a different Overpass mirror so a slow mirror stalls one quarter rather than everything. The query asks for building centroids only, not polygons, which is what keeps a 45,000-building query answerable; each centroid increments a per-cell structure count and adds its value weight. A second, tiny query fetches the tagged facilities (hospital, clinic, school, fire station, police, substation, power plant) that carry the higher weights.

  • Quadrants stream in independently. Each arrival re-assembles the scenario and repaints the map, and the structure count in the header climbs as they land.
  • If a quadrant fails outright, the loader falls back to land-use polygons rasterised at a flat density of six structures per cell, and the scenario is marked so it is not cached; the next visit retries.
  • Water polygons come from a separate Overpass call on a different mirror and are ray-cast rasterised onto the grid. Until they arrive, anything at sea level is water.

Overpass rate limits are real. While writing this I hit them repeatedly from a script that reloaded the Palisades scenario several times in a row, which is precisely the pattern the browser cache exists to prevent: a complete scenario is stored locally at about 250 kilobytes, and returning to a region costs no network at all.

Weather: ERA5, hourly, for any date

Weather comes from the Open-Meteo archive of ERA5 reanalysis: hourly temperature, humidity, precipitation, wind speed, direction, and gusts, in miles per hour and UTC, from 1940 to about five days ago. For the Palisades window that is 240 hourly samples covering the ignition on 7 January 2025 through the 16th. The timeline precomputes a rolling 48-hour precipitation total per sample, which the fuel-moisture model uses as rain memory, and interpolates linearly between samples when the engine asks for a time in between. If the archive is unreachable, a small bundled set of airport observations serves as the weather of last resort, and the source chip says so.

// rolling 48 h precipitation per sample
let j = 0, sum = 0;
for (let i = 0; i < samples.length; i++) {
  sum += samples[i].precip;
  while (samples[i].timeMs - samples[j].timeMs > 48 * 3600000) sum -= samples[j++].precip;
  samples[i].rain48 = sum;
}
weatherTimeline.js: rain memory is a two-pointer sliding window over the samples, computed once.

Why reanalysis rather than a forecast

ERA5 is a hindcast: the best estimate of what the weather was, on a grid, every hour. For replaying a historical fire it is exactly right, and for the model's Monte Carlo ensemble it means the members share one deterministic weather history and diverge only through the engine's own stochastic channels. That is a limitation I state plainly in the paired-seed article: the ensemble is not a set of alternative forecasts. A live-incident version would swap the archive endpoint for a forecast one, and the timeline abstraction would not notice.

The perimeter: ground truth from the incident feed

For a real fire, the loader queries the national incident feature service for perimeters whose discovery date falls within a few days of the scenario window and whose geometry intersects the box, takes the largest match, and scanline rasterises it onto the grid. For Palisades that is the recorded 23,448-acre perimeter, 3,800 cells of which fall inside the box. It is the only source that is allowed to simply be missing: a scenario with no recorded fire has nothing to validate against, and the panel says so.

What the perimeter is for

The model has one calibration knob, a multiplier on the base rate of spread, and it is fitted by sweeping seven values on a geometric ladder, replaying the whole fire three times per value, and picking the multiplier that maximises overlap with the observed footprint. Overlap is intersection over union rather than area, because a model can burn the right area on entirely the wrong ridge and area would reward it. Water is excluded from the score on both sides; a third of the Palisades box is Pacific.

  • Overlap with the real perimeter (IoU)
  • Share of the real footprint reached
0.000.250.500.751.00×0.6: 0.3% of the footprint reached, 0.2 km² burned×0.6: IoU 0.003×0.60 km²×0.9: 9.7% of the footprint reached, 8.6 km² burned×0.9: IoU 0.096×0.99 km²×1.4: 37.3% of the footprint reached, 33.4 km² burned×1.4: IoU 0.357×1.433 km²×2.1: 99.5% of the footprint reached, 144.5 km² burned×2.1: IoU 0.552×2.1145 km²×3.2: 100.0% of the footprint reached, 189.6 km² burned×3.2: IoU 0.424×3.2190 km²×4.8: 100.0% of the footprint reached, 190.5 km² burned×4.8: IoU 0.422×4.8191 km²×7.2: 100.0% of the footprint reached, 192.7 km² burned×7.2: IoU 0.417×7.2193 km²fitted: ×2.1, IoU 0.55
View as table
Calibration sweep, three replicates per multiplier, 198-hour replay
MultiplierBurned km²IoUFootprint reached
×0.60.20.0030.3%
×0.98.60.0969.7%
×1.433.40.35737.3%
×2.1144.50.55299.5%
×3.2189.60.424100.0%
×4.8190.50.422100.0%
×7.2192.70.417100.0%
The calibration sweep for Palisades, run headless for this article. Overlap with the recorded perimeter peaks at 0.55 at a multiplier of 2.1, where the simulated fire reaches 99.5 percent of the real footprint; beyond that it over-burns and the overlap falls. The fitted fire is too large by about a third, which is the honest number.

The reason for a single knob is written in the validation module: fitting many coefficients to one fire would just memorise it, while one well-understood knob can be justified physically. Out of the box, uncalibrated, the model under-burns the Palisades fire badly; fitted, it tracks the footprint well enough that comparative claims between response strategies carry information. The calibration is cached per location and start year in local storage, so the “calibrated” chip survives a reload.

If you build on open geodata in the browser

  1. Rasterise everything onto one grid at load, in typed arrays, and never let the model touch a source directly.
  2. Fetch what the model needs, not what the source offers: centroids, not polygons; hourly samples, not a full reanalysis file.
  3. Split big requests and start each part on a different mirror. Rate limits are per endpoint.
  4. Give every layer a fallback, mark fallback scenarios so they are not cached, and surface the provenance to the user.
  5. Abort what you no longer need. A superseded load that keeps writing into state is the bug you will spend a weekend on.

The engine that consumes all of this, and the front-end that keeps it smooth, are covered in the case study and in the React article. The scenarioLoader.js assembly function is the place to start reading if you want to reuse the approach for another kind of model.

Book a 30-min callEmail about this work