Skip to content

DHM warning maps

Sanam edited this page Oct 7, 2026 · 1 revision

DHM publishes its district warnings only as images: three maps per bulletin, one per day, about 08:00 and 18:00 Nepal time. DhmWarningMapSource reads each district's level off them.

var warnings = new DhmWarningMapSource(http, store, TimeProvider.System);
var result = await warnings.FetchAsync(CancellationToken.None);

if (result.Value is { } snapshot)
{
    var jhapa = Gazetteer.Districts.Single(d => d.Id == "jhapa");
    foreach (var day in snapshot.Days)
    {
        Console.WriteLine($"{day}: {snapshot.LevelOn(jhapa, day)}");
    }
}

How it reads a map

  1. One request lists the newest bulletins (dhm.gov.np/mfd/api/page?type=8). It takes the newest published one with maps for days 1 to 3.
  2. If that bulletin and its image files are what it read last time, it reuses the stored reading and fetches nothing else. Otherwise it fetches the three PNGs.
  3. The maps are plotted on longitude and latitude axes, so every pixel has a position. Each district's level is the fill colour most of its pixels have.
  4. Day 1 is the Nepal date the bulletin was issued; days 2 and 3 follow.

A poll costs 1 request, or 4 when a new bulletin is out. Set the host interval for dhm.gov.np to 5 seconds.

Fill colour (RGB) Level
(77, 229, 7) Green
(255, 248, 9) Yellow
(252, 144, 12) Orange
(239, 1, 2) Red

The legend's colours are not the fill colours, and district borders are sometimes drawn in the legend's red (255, 0, 0). Reading the legend colours would count every border as a Red warning.

How well it works

Checked on 36 maps from 2026-06-29 to 2026-10-06: on every one, each district's pixels were at least 98 percent one fill colour. A live run on 2026-10-06 read 31, 47 and 41 Yellow districts for the three days, the same counts a separate script read from the same images.

When it cannot read a map

The source reports Drifting and gives no levels, so the official rule says Unknown. That happens when:

  • the image is not 1300 by 800, or the axis ticks moved;
  • a district has fewer than 8 sample pixels in a fill colour, or no colour has 80 percent;
  • the image is not a PNG it reads (8-bit, not interlaced, at most 2048 pixels a side).

Image paths from DHM's list must look like weather-map/YYYY/MM/DD/<name>.png; anything else is drift and is never fetched.

Limits

  • The hazard (rain, snow, wind) is drawn as an icon and is not read. Warnings carry Hazard.Unspecified and the district's highest level.
  • If DHM swapped two fill colours and kept the layout, the reader would not notice. Every other layout change shows as drift.
  • The stored snapshot is the reading (each image's URL and SHA-256, and all 77 districts' levels per date), not the images.

Clone this wiki locally