Skip to content

Flood hazard icon Floods example

Business question

For a given country, which flood events affected the largest populations, and is any of them still active?

We use adam.adam_fl_events, keeping in mind two quirks of this collection (both documented in Recurring Date Queries): the datetime= parameter does not work here, and cleared is a string 'yes'/'no' — not a boolean.

Step-by-step from a terminal

1. Top floods for a country, ranked by affected population

curl -sS -H "Accept: application/geo+json" \ "https://api.adam.geospatial.wfp.org/api/collections/adam.adam_fl_events/items?limit=5&sortby=-fl_popn&filter=iso3%20%3D%20'BGD'" \ | jq '{numberMatched, sample: (.features[0].properties | {country, effective, cleared, fl_popn, fl_croplnd, flood_area})}'
{
"numberMatched": 42,
"sample": {
"country": "Bangladesh",
"effective": "2024-07-12",
"cleared": "yes",
"fl_popn": 3450123,
"fl_croplnd": 412000,
"flood_area": 28900
}
}

2. Isolate the still-active events

cleared = 'no' — string comparison, not boolean:

curl -sS -H "Accept: application/geo+json" \ "https://api.adam.geospatial.wfp.org/api/collections/adam.adam_fl_events/items?limit=5&sortby=-fl_popn&filter=iso3%20%3D%20'BGD'%20AND%20cleared%20%3D%20'no'" \ | jq '{numberMatched, sample: (.features[0].properties | {country, effective, fl_popn, flood_area})}'

3. Flood date windows with string comparison

datetime= does not work on flood events, but effective > '2026-04-01T00:00:00' works as lexicographic string comparison (ISO-8601 ordering == alphabetic ordering):

curl -sS -H "Accept: application/geo+json" \ "https://api.adam.geospatial.wfp.org/api/collections/adam.adam_fl_events/items?limit=5&sortby=-fl_popn&filter=effective%20%3E%20'2026-04-01T00:00:00'" \ | jq '{numberMatched}'

Python recap

import json
import urllib.parse
import urllib.request

BASE = "https://api.adam.geospatial.wfp.org/api"
COUNTRY = "BGD"
MIN_POP = 50_000

params = urllib.parse.urlencode({
    "filter": f"iso3 = '{COUNTRY}' AND fl_popn >= {MIN_POP}",
    "sortby": "-fl_popn",
    "limit": 100,
})
url = f"{BASE}/collections/adam.adam_fl_events/items?{params}"
req = urllib.request.Request(url, headers={"Accept": "application/geo+json"})

with urllib.request.urlopen(req) as r:
    fc = json.loads(r.read())

total_pop = sum(f["properties"].get("fl_popn", 0) for f in fc["features"])
print(f"{fc['numberMatched']} flood events in {COUNTRY}, total population affected: {total_pop:,.0f}")

Interactive — marimo playground

Change the ISO3 code or the minimum-population threshold and the ranked table + chart update live.

Download: floods.py

Try it yourself

Live references

Next steps