---
title: "Flood damage, exposure and population affected in Python: the Valencia floods of October 2024"
description: "Count flooded buildings, damage and people affected by the 2024 Valencia floods in Python with Copernicus EMS, Overture Maps, GHSL, WorldPop and INE."
url: https://www.technicalgis.com/tutorials/flood-damage-exposure-population-python/
author: Sean Blaney (https://www.technicalgis.com/about/#sean-blaney)
publisher: TechnicalGIS (https://www.technicalgis.com/about/)
published: 2026-12-01
updated: 2026-12-01
language: en-GB
---

# Flood damage, exposure and population affected in Python: the Valencia floods of October 2024

> Count flooded buildings, damage and people affected by the 2024 Valencia floods in Python with Copernicus EMS, Overture Maps, GHSL, WorldPop and INE.

- Level: Intermediate
- Tested with: Python 3.12
- Source code: [Download scripts](https://www.technicalgis.com/code/flood-damage-exposure-population-python/)

Series · Part 3 of 6

## [GIS for disaster emergency response](https://www.technicalgis.com/tutorials/series/disaster-emergency-response-gis/)

1.  [Rapid situational mapping from open data in Python: the Valencia floods of 29 October 2024](https://www.technicalgis.com/tutorials/rapid-situational-mapping-open-data-python/)
2.  [Satellite flood mapping with Sentinel-1 and Sentinel-2: the Valencia floods of October 2024](https://www.technicalgis.com/tutorials/satellite-flood-mapping-sentinel-1-sentinel-2/)
3.  Flood damage, exposure and population affected in Python: the Valencia floods of October 2024

Part 4 is out 8 December 2026. [See the whole series](https://www.technicalgis.com/tutorials/series/disaster-emergency-response-gis/)

## Key takeaways

1.  In the Copernicus EMS area of interest for L'Horta Sud (279 km²), 9,217 Overture buildings touched the 47.8 km² mapped flood extent, and EMS graded 2,743 of them as damaged or destroyed.
2.  Check the flood extent against the damage grading before you count anything: the EMS delineation product held only 18% of the graded building points, the grading product's own extent held 93%.
3.  GHSL and WorldPop put 70,938 and 83,372 people in flooded buildings. Report the range, not one number; WorldPop matched the INE register within 10% in 22 of 27 municipalities, GHSL in 6.
4.  A per-municipality table with people, buildings, graded damage and damaged roads is what responders can act on; Paiporta, Sedaví, Alfafar and Beniparrell each had more than a third of residents in a flooded building.

## Before you start

-   Comfortable with GeoPandas and rasterio; spatial joins and zonal statistics are covered in their own tutorials
-   Python 3.10+ with duckdb, geopandas, pyogrio, shapely, rasterio, numpy, pandas, matplotlib, requests, pyarrow and openpyxl
-   An internet connection with no account or key: the first run downloads about 290 MB (Copernicus EMS products, WorldPop, GHSL tiles and GISCO boundaries) plus about 25 MB of Overture buildings, then runs in one to two minutes

**Short answer:** to estimate flood exposure in Python, take a flood extent (here the Copernicus EMS products for EMSR773), select the building footprints that touch it (Overture Maps, queried with DuckDB), and attach the EMS damage grade to each footprint. Then spread each population grid cell’s residents over the floor area of the homes in that cell, and add up the people in flooded homes. Do it with two grids, GHSL and WorldPop, check both against the official register, and report a range per municipality. For L’Horta Sud the result was 9,217 buildings in the flood, 2,743 graded damaged or destroyed, and between 70,938 and 83,372 people living in flooded buildings.

This is Part 3 of **[GIS for disaster emergency response](https://www.technicalgis.com/tutorials/series/disaster-emergency-response-gis/)**. In [Part 1](https://www.technicalgis.com/tutorials/rapid-situational-mapping-open-data-python/) we built a first-hours situation map, and in [Part 2](https://www.technicalgis.com/tutorials/satellite-flood-mapping-sentinel-1-sentinel-2/) we mapped the flood from satellites and scored the map against Copernicus EMS. Now we ask the questions that follow every flood map: how many buildings, how much damage, and how many people?

On the evening of 29 October 2024 the Poyo ravine and its neighbours overflowed after a DANA (a cut-off low) stalled over the Valencia region, flooding Paiporta, Picanya, Massanassa, Catarroja, Sedaví, Alfafar and the towns around them. More than 220 people died: the Spanish government counted 229, 221 of them in the Comunitat Valenciana, on 24 November 2024 ([La Moncloa](https://www.lamoncloa.gob.es/info-dana/Paginas/2024/241124-datos-seguimiento-actuaciones-gobierno.aspx)). Civil protection, the municipalities and NGOs needed to know where to send people, pumps and supplies, street by street and town by town. This tutorial builds that picture from open data and is careful about how sure each number is.

You will learn how to:

1.  download the Copernicus EMS **delineation and damage grading** products and check which flood extent fits the damage;
2.  join municipal boundaries to the **INE register** to get an official population for each one;
3.  query **Overture Maps buildings** for a bounding box with DuckDB, straight from the cloud;
4.  count buildings in the flood and attach the **EMS damage grade** to each footprint;
5.  estimate the **people affected** with GHSL and WorldPop, spreading each grid cell over home floor space, and test both grids against INE;
6.  summarise everything **per municipality** as a table, a GeoPackage and a choropleth.

| Role | Dataset | Source |
| --- | --- | --- |
| Flood extent and damage | EMSR773 AOI03 Horta Sud: delineation (DEL v1) and grading (GRA v2), imagery of 31 October 2024 | Copernicus EMS Rapid Mapping |
| Buildings | Footprints with subtype and number of floors, release 2026-10-21.0 | Overture Maps Foundation (from OpenStreetMap, IGN and Microsoft) |
| Population grids | GHS-POP E2025 (100 m) and WorldPop Spain 2024 constrained (3 arcsec) | JRC; WorldPop |
| Boundaries | Local administrative units 2024 | Eurostat GISCO |
| Official population | Padrón, 1 January 2024, table 2903 | INE |

All outputs below are real results from [`flood_exposure.py`](https://www.technicalgis.com/code/flood-damage-exposure-population-python/), run on 17 November 2026 with Python 3.12.0, geopandas 1.2.0, duckdb 2.0.0 and rasterio 1.5.2. Each part of this series stands on its own, so the script downloads its own flood extent rather than reusing Part 2’s.

## Step 1: download the Copernicus EMS products

EMS split EMSR773 into several areas of interest (AOIs). AOI03, Horta Sud, is the one that covers the worst-hit towns with both a **delineation** product (where the water was) and a **grading** product (what it damaged), both from very high resolution GeoEye-1 and WorldView-2 images of 31 October. It lies a little west of the series’ default study box, which is why we use the AOI itself as our study area. The activation’s public JSON lists every product and its download link.

`flood_exposure.py`

```python
act = json.loads(act_file.read_text(encoding="utf-8"))["results"][0]
aoi03 = next(a for a in act["aois"] if a["number"] == 3)
products = {}
for p in aoi03["products"]:
    kind = {"DEL": "delineation", "GRA": "grading"}[p["type"]]
    zpath = download(p["downloadPath"], DATA / Path(p["downloadPath"]).name)
    products[kind] = zpath

aoi = pd.concat([read_ems(products[k], "areaOfInterestA") for k in products]).union_all()
flood_del = read_ems(products["delineation"], "observedEventA")
flood_gra = read_ems(products["grading"], "observedEventA")
grading = read_ems(products["grading"], "builtUpP")        # one point per graded building
roads = read_ems(products["grading"], "transportationL")   # graded road and rail segments
```

`read_ems` opens one shapefile layer straight from the zip and reprojects it to ETRS89 / UTM zone 30N (EPSG:25830), so areas come out in square metres.

Both products contain a flood extent, and they differ. Which one should we count against? The grading gives us an independent test: a building that analysts graded as damaged by the flood should sit inside the flood extent. So we count the graded points inside each extent.

`Output — Step 1`

```text
EMSR773: Flood in Valencia Region, Spain | event 2024-10-29T14:30:00 UTC | activated 2024-10-29T16:40:00 UTC
GRA grading     EMSR773_AOI03_GRA_PRODUCT_v2.zip (71 MB) | imagery: GeoEye-1 2024-10-31 10:22
DEL delineation EMSR773_AOI03_DEL_PRODUCT_v1.zip (17 MB) | imagery: GeoEye-1 2024-10-31 10:22, WorldView-2 2024-10-31 10:22
AOI03 (delineation + grading AOIs): 278.7 km2
flood polygons in the delineation product: 617 | 24.1 km2 (flood trace 23.2, flooded area 0.8)
flood polygons in the grading product: 1,528 | 42.9 km2 (flood trace 36.5, flooded area 6.5)
overlap 19.2 km2 | union 47.8 km2
graded building points: 3,906 | {'Possibly damaged': 611, 'Damaged': 3258, 'Destroyed': 37}
graded points inside each flood extent: delineation 18% | grading 93% | union 93%
```

The answer is clear. The first delineation (v1) mapped 24.1 km², almost all of it flood trace: ground that had dried by the time of the image, recognised from mud and debris. The later grading product (v2) mapped 42.9 km² and contains 93% of the damaged buildings; the delineation contains 18%. Two days after a flash flood, the water had largely gone, and the analysts refined the extent while they graded the damage. We use the **union** of the two, 47.8 km², so that nothing either product saw is lost.

![Two maps of Copernicus EMS area of interest AOI03, Horta Sud, west and south of Valencia city, with municipal boundaries and grey Overture building footprints. Left: the delineation product's flood extent in blue, 24.1 km², a patchy band along the Poyo ravine from Torrent and Quart de Poblet in the west to Paiporta and Catarroja in the east, with many orange, red and dark red damage points falling outside it. Right: the grading product's extent, 42.9 km², which is wider and continuous, covers the industrial estates north of Aldaia and Quart de Poblet and the marshland towards the Albufera in the south-east, and contains nearly all the damage points.](https://www.technicalgis.com/_astro/01-ems-flood-extents.TjZYkVXl_Z2kSUqa.webp)

_The two EMS flood extents for AOI03 from imagery of 31 October 2024, with the graded buildings. The grading product's extent contains 93% of the damaged buildings; the earlier delineation contains 18%._

## Step 2: municipalities and their official population

Responders work by municipality, so every count ends up in one. We read the 2024 local administrative units from Eurostat GISCO, keep those that touch AOI03, and join the INE Padrón of 1 January 2024. The GISCO ID for a Spanish municipality is `ES_` followed by the five-digit INE code, so the join is a string slice.

`flood_exposure.py`

```python
lau = gpd.read_file(f"zip://{download(LAU_URL, DATA / Path(LAU_URL).name).as_posix()}",
                    bbox=(-0.75, 39.30, -0.30, 39.56))
lau = lau[lau.CNTR_CODE == "ES"].to_crs(CRS)
munis = lau[lau.intersects(aoi)].copy()
munis["ine_code"] = munis.GISCO_ID.str[3:]
munis["share_in_aoi"] = munis.intersection(aoi).area / munis.area
...
munis = munis.merge(ine, on="ine_code", how="left").sort_values("share_in_aoi", ascending=False)
```

The INE table comes from its open JSON API (`servicios.ine.es/wstempus/js/ES/DATOS_TABLA/2903`), one series per municipality and sex; we keep the totals.

`Output — Step 2`

```text
266 municipalities in Valencia province in the INE table; 27 touch AOI03; INE population missing for 0
wholly or mostly (>= 90%) inside AOI03: 13 municipalities, 343,532 residents
partly inside: Sedaví 83%, Catarroja 79%, Massanassa 62%, Manises 41%, Silla 40%, Alfafar 40%, Picassent 27%, Riba-roja de Túria 21%, Montserrat 18%, València 18%, Cheste 13%, Chiva 10%, Loriguilla 6%, Paterna 1%
```

The `share_in_aoi` column matters later. EMS only mapped inside the AOI, so for València (18% inside) or Alfafar (40%) our counts cover only part of the municipality. The summary table carries this share so nobody reads a partial count as a whole one.

## Step 3: Overture Maps buildings with DuckDB

Overture Maps publishes buildings for the whole world as GeoParquet on Amazon S3, with a `bbox` column that lets DuckDB read only the row groups it needs. We ask the Overture STAC catalogue for the latest release and the files that overlap our box, then copy the buildings into a local Parquet file. The [GeoParquet and DuckDB tutorial](https://www.technicalgis.com/tutorials/geoparquet-duckdb-overture-maps/) explains the pattern in detail.

`flood_exposure.py`

```python
release = requests.get("https://stac.overturemaps.org/catalog.json", timeout=60).json()["latest"]
x0, y0, x1, y1 = gpd.GeoSeries([aoi.buffer(500)], crs=CRS).to_crs(4326).total_bounds
con = duckdb.connect()
con.sql("INSTALL spatial; LOAD spatial; INSTALL httpfs; LOAD httpfs; SET s3_region = 'us-west-2';")
bbox_sql = f"bbox.xmin <= {x1} AND bbox.xmax >= {x0} AND bbox.ymin <= {y1} AND bbox.ymax >= {y0}"
files = [r[0] for r in con.sql(f"""
    SELECT assets.aws.alternate.s3.href FROM read_parquet('https://stac.overturemaps.org/{release}/collections.parquet')
    WHERE collection = 'building' AND {bbox_sql}""").fetchall()]
con.sql(f"""
    COPY (SELECT id, subtype, class, height, num_floors,
                 list_filter(sources, lambda s: s.property = '')[1].dataset AS source,
                 '{release}' AS release, geometry
          FROM read_parquet({files}) WHERE {bbox_sql})
    TO '{bld_file.as_posix()}' (FORMAT parquet)""")
```

Back in GeoPandas we compute each footprint’s area, estimate floor space from `num_floors` (one floor where it is missing), and flag the buildings that could hold residents: anything not tagged industrial, commercial, civic and so on, with at least 30 m² of footprint.

`flood_exposure.py`

```python
bld["footprint_m2"] = bld.area
bld["floors"] = bld.num_floors.fillna(1).clip(1, 30)
bld["home"] = ~bld.subtype.isin(NOT_HOMES) & (bld.footprint_m2 >= 30)  # could hold residents
```

`Output — Step 3`

```text
Overture release 2026-10-21.0: 160,567 buildings in AOI03 + 500 m, 107,856 inside AOI03
source of the footprint: {'OpenStreetMap': 71691, 'Instituto Geográfico Nacional (España)': 35696, 'Microsoft ML Buildings': 469}
with num_floors: 80% | with a subtype: 23% | could hold residents: 65%
```

Two thirds of the footprints come from OpenStreetMap and a third from Spain’s national cadastre-based building layer (IGN), so coverage is good. Floors are known for 80% of buildings, but only 23% have a subtype. That gap matters in Step 5.

## Step 4: buildings in the flood and the EMS damage grade

A building is exposed if its footprint touches the flood extent. With 160,000 footprints and a flood made of thousands of polygons, a plain `intersects` against one huge multipolygon is slow, so the small `touches` helper explodes the flood into parts and uses a spatial join, which builds a spatial index.

`flood_exposure.py`

```python
def touches(geoms: gpd.GeoSeries, area) -> np.ndarray:
    """True where a geometry intersects `area`, via a spatial index on the area's parts (fast for many features)."""
    parts = gpd.GeoDataFrame(geometry=gpd.GeoSeries([area], crs=CRS).explode(index_parts=False).values, crs=CRS)
    hit = gpd.sjoin(gpd.GeoDataFrame(geometry=geoms.values, crs=CRS), parts, predicate="intersects").index.unique()
    return np.isin(np.arange(len(geoms)), hit)

for name, ext in extents.items():
    bld[f"in_{name}"] = touches(bld.geometry, ext)
bld["flooded"] = bld.in_union
```

The EMS grading is a point per building. We attach each point to the Overture footprint it falls in, or to the nearest footprint within 10 m, and keep the worst grade where several points land on one building. The grading also records the analysts’ view of each building’s use, which lets us correct Overture: a building EMS classed as non-residential is not counted as a home.

`flood_exposure.py`

```python
gp = gpd.sjoin(grading[["damage_gra", "obj_type", "geometry"]], bld[["geometry"]], how="left", predicate="within")
gp = gp[~gp.index.duplicated()]
miss = gp.index_right.isna()
near = gpd.sjoin_nearest(grading[miss][["geometry"]], bld[["geometry"]], how="left", max_distance=10)
gp.loc[miss, "index_right"] = near[~near.index.duplicated()].index_right
gp["rank"] = gp.damage_gra.map({g: i for i, g in enumerate(GRADE_ORDER)})
worst = gp.dropna(subset=["index_right"]).groupby("index_right")["rank"].max()
bld["ems_grade"] = pd.Series(np.array(GRADE_ORDER)[worst.to_numpy()], index=worst.index.astype(int))
non_res = gp[gp.obj_type.str.startswith("12-")].index_right.dropna().astype(int).unique()
bld.loc[non_res, "home"] = False
```

`Output — Step 4`

```text
footprint touches the flood: 9,217 buildings (6.97 km2 of roof, 9.78 km2 of floor space)
centroid inside the flood instead: 7,742 buildings
by flood extent: delineation only 4,004 | grading product 8,609 | union 9,217
flooded buildings by Overture subtype: {'(none)': 5379, 'industrial': 2534, 'residential': 860, 'commercial': 123, 'civic': 112, 'outbuilding': 94}
EMS grading points on an Overture footprint: 3,316 of 3,906; within 10 m: 515; unmatched: 75
graded buildings: {'Possibly damaged': 542, 'Damaged': 2707, 'Destroyed': 36}
Overture 'homes' the EMS grading classes as non-residential: 867 (now excluded)

share of EMS-graded buildings inside each flood extent (a check on the extent):
  delineation  all  38.7% | possibly damaged 35.2% | damaged 38.8% | destroyed 88.9%
  grading      all  96.5% | possibly damaged 82.1% | damaged 99.3% | destroyed 100.0%
  union        all  96.5% | possibly damaged 82.3% | damaged 99.3% | destroyed 100.0%

graded transport lines (km):
damage_gra   Possibly damaged  Damaged  Destroyed
simplified
Local roads             208.4     44.4        0.3
Tracks                  180.7     37.0        4.5
Highway                  16.2     24.5        0.1
Railways                 11.4      3.8        0.0
Main roads                8.8      2.0        0.0
Subways                   4.3      0.5        0.0
Airfield                  0.0      0.2        0.0
```

9,217 buildings touched the flood; counting by centroid instead gives 7,742, so the rule you choose moves the answer by 16%. “Touches” suits responders, because water at the door is enough to need help. The choice of extent matters even more: the first delineation alone would have found 4,004.

The graded buildings confirm the union extent. All 36 destroyed buildings and 99.3% of the damaged ones touch it. The “possibly damaged” grade fits less well (82%), which is expected: it is the least certain class and includes buildings on the fringe of the water. More than 2,500 of the flooded buildings are industrial. Nobody lives in them, but they matter for jobs, for recovery and for pollution from flooded premises.

The transport table gives the first figure for engineers: 44 km of local roads, 24.5 km of highway and 3.8 km of railway graded damaged. Part 4 of the series removes flooded roads from the network to measure what that does to access.

![Detailed map of Paiporta, Benetússer, Massanassa, Sedaví, Alfafar and the edge of Picanya, about 4 km across, with the flood extent in light blue. Buildings not in the flood are light grey. Flooded buildings that EMS did not grade are dark blue; graded buildings are orange (possibly damaged), red (damaged) or dark red (destroyed). Large red warehouses fill the industrial area north-east of Paiporta, red and blue homes line the Poyo ravine through Paiporta, and the flood covers Massanassa and the industrial land east of Alfafar. Black lines mark roads and railways graded damaged. Municipal boundaries are dotted grey lines with a 500 m scale bar.](https://www.technicalgis.com/_astro/02-buildings-damage-paiporta.BKZ_v3E6_16BbfM.webp)

_Paiporta and its neighbours along the Poyo ravine. Flooded Overture footprints are coloured by the EMS damage grade; dark blue buildings were in the flood but not graded._

## Step 5: people in the flood from two population grids

Neither GHSL nor WorldPop tells you who lives in which building. Both give residents per grid cell: GHSL per 100 m cell in the Mollweide projection, WorldPop per 3 arcsecond cell (about 72 by 92 m here). The crude estimate is **area-weighted**: multiply each cell’s people by the share of the cell that is flooded. A better one is **building-weighted** (dasymetric): spread each cell’s people over the floor space of its homes, then count the people in the flooded ones. A cell that is half flooded may have all of its flats on the dry half.

`flood_exposure.py`

```python
xy = bld.representative_point().to_crs(gcrs)
rr, cc = (np.asarray(v) for v in rasterio.transform.rowcol(tr, xy.x.values, xy.y.values))
inside = (rr >= 0) & (rr < pop.shape[0]) & (cc >= 0) & (cc < pop.shape[1])
c = bld[inside].assign(cell=rr[inside] * pop.shape[1] + cc[inside], w=lambda d: d.footprint_m2 * d.floors)
bw = f_flood.ravel().copy()
for sel in [c, c[c.home]]:  # homes overwrite all buildings
    tot = sel.groupby("cell").w.sum()
    share = (sel[sel.flooded].groupby("cell").w.sum() / tot).reindex(tot.index).fillna(0)
    bw[share.index.to_numpy()] = share.to_numpy()
bw = bw.reshape(pop.shape)
```

`bw` is the share of each cell’s residents who live in flooded buildings. It starts as the flooded share of the cell’s area (`f_flood`, from a rasterisation at ten times the grid resolution), is replaced by the flooded share of all floor space where the cell has buildings, and by the flooded share of home floor space where it has homes. Each cell’s people times `bw`, summed by municipality, is the estimate. The [zonal statistics tutorial](https://www.technicalgis.com/tutorials/zonal-statistics-python/) covers the simpler area-based version.

Before trusting either grid, we compare its total for each whole municipality with the INE register.

`Output — Step 5`

```text
GHSL: 680 x 476 cells (~100 m) | total 1,823,963 people | in the flood: area-weighted 64,537, building-weighted 70,938
  of which in flooded homes 41,227; in cells where Overture has no home 29,711
WorldPop: 975 x 528 cells (~72 m) | total 1,898,202 people | in the flood: area-weighted 77,454, building-weighted 83,372
  of which in flooded homes 38,951; in cells where Overture has no home 44,421

grid totals against the INE Padron (1 January 2024), all 27 municipalities:
  GHSL     sum 1,391,349 vs INE 1,455,252 (-4.4%) | per municipality median -14.9%, middle half -17.8% to -10.0% | within 10%: 6 of 27
  WorldPop sum 1,396,741 vs INE 1,455,252 (-4.0%) | per municipality median -2.1%, middle half -6.1% to +0.1% | within 10%: 22 of 27
```

Both grids land within 5% of the INE total, but that is mostly València city. Municipality by municipality, WorldPop is much closer: it matched 22 of 27 within 10%, GHSL only 6, with a typical shortfall of 15% that is largest in the small towns. WorldPop is built from Spanish census counts and constrained to mapped settlements; GHSL is a global product tuned for consistency between countries.

The two grids give 70,938 and 83,372 people in flooded buildings, so we carry both as a range. Building weighting raised both estimates slightly over area weighting: within the cells it touched, the flood fell on built-up ground more often than on gardens and fields.

The second line under each grid is a check on the method. Only 41,227 (GHSL) and 38,951 (WorldPop) people sit in flooded buildings that Overture lets us call homes. The rest are in cells where every flooded building is industrial, untagged non-residential, or absent, so they were counted by floor space or area instead. Some of these people are real residents of buildings Overture tags poorly; some are grid errors near industrial estates. Read the lower figure as the people we can place in a specific home and the higher one as the total exposure.

![Three panels. Left and centre: GHSL and WorldPop population per grid cell over AOI03 on a log colour scale from 1 (pale yellow) to 1,000 (black) people per cell, with the flood extent outlined in blue. Both show dense purple cells in València city to the north-east and in the towns of L'Horta Sud along the Poyo ravine, and pale or empty cells in the fields to the west; WorldPop is smoother and spreads people over more cells. Titles give 70,938 people in flooded buildings for GHSL and 83,372 for WorldPop. Right: a log-log scatter of each grid's total against the INE register for the 27 municipalities; points fall close to the 1:1 line, with GHSL's green circles mostly just below it and WorldPop's purple squares on it.](https://www.technicalgis.com/_astro/03-population-grids.BNz2vpna_1qUVeT.webp)

_The two population grids, with the flood outlined, and their municipal totals against the INE register. WorldPop is within 10% of INE in 22 of 27 municipalities; GHSL in 6._

## Step 6: a summary per municipality for responders

Everything now comes together by municipality: the flooded area (an overlay), counts of flooded buildings and graded damage (a group-by on each building’s municipality, which a [spatial join](https://www.technicalgis.com/tutorials/spatial-join-geopandas/) supplied), damaged roads and railways excluding farm tracks, and the population range.

`flood_exposure.py`

```python
flood_by_muni = gpd.overlay(munis[["name", "geometry"]], gpd.GeoDataFrame(geometry=[FLOOD], crs=CRS), how="intersection")
m["flood_km2"] = m["name"].map(flood_by_muni.dissolve("name").area / 1e6).fillna(0)
fb = bld[bld.flooded]
m["bldg_flooded"] = m["name"].map(fb.groupby("muni").size()).fillna(0).astype(int)
dmg = bld[bld.ems_grade.isin(["Damaged", "Destroyed"])]
m["ems_damaged_destroyed"] = m["name"].map(dmg.groupby("muni").size()).fillna(0).astype(int)
rd = roads[roads.damage_gra.isin(["Damaged", "Destroyed"]) & ~roads.simplified.isin(["Tracks"])]
m["roads_damaged_km"] = m["name"].map(rd.groupby("muni").km.sum()).fillna(0)
m["affected_low"] = m[["aff_GHSL", "aff_WorldPop"]].min(axis=1)
m["affected_high"] = m[["aff_GHSL", "aff_WorldPop"]].max(axis=1)
m["affected_mid"] = m[["aff_GHSL", "aff_WorldPop"]].mean(axis=1)
m["affected_pct"] = 100 * m.affected_mid / m.pop_ine_2024
```

`Output — Step 6`

```text
        municipality INE pop mapped flood km2 bldgs flooded EMS dmg+destr roads dmg km people (GHSL-WorldPop) % of pop in homes
            València 825,948    18%      3.81         1,036           298          0.0           9,135-11,732       1%      52%
            Paiporta  27,748   100%      2.18           667           187          0.2           8,456-11,172      35%      58%
           Catarroja  30,142    79%      3.62           948           310          0.0            7,645-8,898      27%      52%
             Alfafar  22,131    40%      2.29           518           181          0.0            7,116-8,498      35%      42%
  Riba-roja de Túria  24,230    21%      6.93           774           305         40.3            7,133-7,793      31%      35%
              Aldaia  34,035   100%      4.00           590            11          3.8            6,452-6,983      20%      43%
     Quart de Poblet  26,304   100%      5.81           739            39          9.9            4,809-5,273      19%      57%
             Torrent  89,401    90%      4.09         1,171           539         10.9            4,372-4,718       5%      84%
              Sedaví  10,908    83%      0.74           346           131          0.0            3,755-4,310      37%      72%
               Albal  17,038    96%      1.85           397           140          0.0            3,075-3,999      21%      43%
          Massanassa  10,345    62%      1.64           445           114          0.0            2,984-3,196      30%      55%
             Picanya  11,876   100%      0.69           178            28          3.6            1,224-1,567      12%      50%
             Alaquàs  30,022   100%      0.62            78             1          1.2            1,124-1,633       5%      48%
         Beniparrell   2,091   100%      1.25           849           346          0.0              981-1,129      50%      42%
          Benetússer  16,322   100%      0.12            68            12          0.0              894-1,087       6%      67%
           Xirivella  31,745   100%      0.28            47             0          0.0                438-684       2%      37%
               Silla  20,117    40%      3.54            46            10          0.0                237-274       1%      13%
              Cheste   9,022    13%      1.08            11             0          0.1                156-225       2%       5%
Llocnou de la Corona     121   100%      0.05           126            90          0.0                153-172     134%     129%
             Mislata  46,153   100%      0.03             1             0          0.0                118-161       0%      28%
          Loriguilla   2,186     6%      0.33            42             0          0.5                 95-160       6%      41%
               Chiva  17,245    10%      2.63           131             1          5.2                 79-100       1%      40%
             Manises  32,273    41%      0.12             2             0          0.0                  34-62       0%       8%
            Alcàsser  10,676   100%      0.13             7             0          0.0                   8-10       0%      21%

AOI03 total: 47.8 km2 flooded | 9,217 buildings (4,113 could hold residents) | 2,743 graded damaged or destroyed | 76 km of roads and railways (not tracks) graded damaged or destroyed
people in flooded buildings: GHSL 70,938 | WorldPop 83,372 (area-weighted: GHSL 64,537 | WorldPop 77,454)

wrote municipality_summary.csv/.xlsx and flood_exposure.gpkg (layers: municipalities, buildings_flooded 9,217, flood_extent)
```

How to read it:

-   **People** is the range between the two grids; **% of pop** divides the midpoint by the whole municipality’s INE population; **in homes** is the share of those people we could place in a specific flooded home.
-   **Paiporta** stands out: the whole town was mapped, about a third of its residents lived in a flooded building, and 58% of them are in identifiable homes. Sedaví (37%), Alfafar (35%) and Beniparrell (50%) are just as hard hit relative to their size.
-   **València** has the largest count but only 1% of its population, because only its southern districts lie in AOI03 (18% mapped).
-   **Torrent** had the most damaged buildings (539) but only 5% of its residents in the flood: Torrent is large, and the flood was a narrow band along the ravine.
-   **Riba-roja de Túria** and **Aldaia** have many people in the flood but few in identifiable homes (35% and 43%). Many of their flooded buildings are in industrial estates, so check them on the ground before sending relief for thousands of households. Riba-roja also has 40 km of damaged roads, the most of any municipality.
-   **Llocnou de la Corona** (121 residents, 0.05 km² of flood) shows more than 100%: it is smaller than the grid cells around it, so the cells assigned to it by their centres hold neighbours’ residents too.

The script writes the same table to CSV and Excel, and a GeoPackage with the municipalities, the 9,217 flooded buildings (with their grade and estimated residents) and the flood extent, ready for QGIS, a web map or a field survey.

The choropleth uses the share of residents affected, not the count, so small towns are not hidden by València. Numbers on the map key it to the bar chart, whose whiskers show the GHSL and WorldPop estimates.

![Left: a choropleth of the municipalities in AOI03, shaded from cream (under 1%) to dark brown (over 40%) by the share of residents living in a flooded building, with the flood extent outlined in blue and the AOI dashed. The darkest municipalities are Beniparrell in the south, then Paiporta, Sedaví, Alfafar, Catarroja and Massanassa in the south-east and Riba-roja de Túria in the north-west, all 20 to 40% or more. Numbered white circles 1 to 14 label the municipalities. Right: a horizontal bar chart of people affected for the same 14 municipalities, from València (about 10,400, 18% mapped) and Paiporta (about 9,800) down to Beniparrell (about 1,050), with whiskers showing the GHSL and WorldPop estimates and the mapped share for partly mapped municipalities.](https://www.technicalgis.com/_astro/04-municipality-choropleth.BSGIEcao_ZaU2Rf.webp)

_Share of each municipality's residents living in a flooded building (left) and people affected by municipality (right). Bars are the mean of GHSL and WorldPop; whiskers are the two estimates._

## Limitations and how to improve them

-   **The extent is from two days later.** Imagery of 31 October shows mostly flood trace; a few buildings at the edge of the flood will be missed or wrongly included.
-   **Only 23% of Overture buildings have a subtype**, so some warehouses still receive residents. Spain’s cadastre (Dirección General del Catastro) records the use of every building and would sharpen the homes.
-   **Floors are not flats.** Floor space is a reasonable proxy for residents, but ground floors in L’Horta Sud are often garages and shops, and in a flash flood it is ground-floor residents who were in most danger. Cadastral dwelling counts or ground-floor flags would refine this.
-   **Grid cells straddle small municipalities**, as in Llocnou de la Corona; assigning people by building location rather than cell centre would fix it.
-   **EMS mapped only AOI03.** Chiva, Cheste and València are only partly covered here; other AOIs of EMSR773 can be added the same way.

## Frequently asked questions

### How do I count the buildings in a flood with Python?

Read the flood extent and the building footprints into GeoPandas in the same metric CRS, then select buildings whose footprints intersect the flood with a spatial join, which uses a spatial index. Decide up front whether “in the flood” means the footprint touches the water or its centroid is inside: here the difference was 9,217 against 7,742 buildings.

### How many people were affected by the Valencia floods in L’Horta Sud?

Within the Copernicus EMS area of interest AOI03, between 70,938 (GHSL) and 83,372 (WorldPop) people lived in buildings that touched the mapped flood extent of 31 October 2024. Of these, about 40,000 lived in buildings we can identify as homes. These are estimates from population grids, not a census of the affected, and they cover only the mapped area.

### Should I use GHSL or WorldPop for population exposure?

Use both and report the range, then check each against the official census for your units. In Valencia, WorldPop matched the INE register within 10% in 22 of 27 municipalities and GHSL in 6, so WorldPop is the better single choice here. GHSL is more consistent between countries, which matters when comparing events.

### Where do I get Copernicus EMS damage grading data?

From the activation page, here [EMSR773](https://rapidmapping.emergency.copernicus.eu/EMSR773), or its public JSON API. Grading products (type GRA) are zip files with shapefiles: `builtUpP` holds a point per graded building with `damage_gra`, and `transportationL` the graded roads and railways. They are free to use with credit to the European Union, Copernicus Emergency Management Service.

### What is dasymetric mapping in flood exposure?

It redistributes population from coarse units, such as 100 m grid cells, to where people actually live, using ancillary data such as building floor area. Rather than assuming people are spread evenly over a cell, you assign them to the cell’s homes and count those in flooded homes.

## Next steps

-   Go back to [Part 1, rapid situational mapping from open data](https://www.technicalgis.com/tutorials/rapid-situational-mapping-open-data-python/), and add this table to the “what we know” summary, or to [Part 2, satellite flood mapping](https://www.technicalgis.com/tutorials/satellite-flood-mapping-sentinel-1-sentinel-2/), and repeat this analysis with your own flood map in place of the EMS extent.
-   Part 4 of the series uses the same flood and population to measure access to hospitals, and Part 5 turns the flooded buildings into a prioritised field survey.
-   Learn more about the Overture query in [GeoParquet, DuckDB and Overture Maps](https://www.technicalgis.com/tutorials/geoparquet-duckdb-overture-maps/), and about joins and zonal sums in [spatial joins with GeoPandas](https://www.technicalgis.com/tutorials/spatial-join-geopandas/) and [zonal statistics in Python](https://www.technicalgis.com/tutorials/zonal-statistics-python/).
-   For damage from radar where no EMS grading exists, see [earthquake damage mapping with Sentinel-1](https://www.technicalgis.com/tutorials/earthquake-damage-mapping-sentinel-1-python/).

## Data and licences

-   **Copernicus EMS Rapid Mapping, activation EMSR773, AOI03 Horta Sud** (delineation DEL v1 and grading GRA v2): © European Union, Copernicus Emergency Management Service. Free, full and open access under the Copernicus data policy (Regulation (EU) 2021/696), with the source credited; see the [terms and conditions](https://mapping.emergency.copernicus.eu/terms-and-conditions/). Downloaded from the [activation page](https://rapidmapping.emergency.copernicus.eu/EMSR773) on 17 November 2026.
-   **Overture Maps buildings**, release 2026-10-21.0: © Overture Maps Foundation. Footprints derived from OpenStreetMap are © OpenStreetMap contributors under the ODbL; those from the Instituto Geográfico Nacional (España) are under CC BY 4.0; Microsoft ML Buildings are under the ODbL. See [Overture attribution](https://docs.overturemaps.org/attribution/). Queried from the [Overture STAC catalogue](https://stac.overturemaps.org/catalog.json) on 17 November 2026.
-   **GHS-POP E2025 R2023A**, 100 m: Schiavina M., Freire S., Carioli A., MacManus K. (2023), European Commission, Joint Research Centre. CC BY 4.0. [GHSL download page](https://human-settlement.emergency.copernicus.eu/download.php?ds=pop), accessed 17 November 2026.
-   **WorldPop** Spain 2024 constrained population, R2025A, 3 arcseconds: WorldPop, University of Southampton. CC BY 4.0. [WorldPop Hub](https://hub.worldpop.org/project/categories?id=3), accessed 17 November 2026.
-   **Local administrative units 2024**: © EuroGeographics for the administrative boundaries, via [Eurostat GISCO](https://ec.europa.eu/eurostat/web/gisco/geodata/statistical-units/local-administrative-units), accessed 17 November 2026.
-   **Padrón municipal population on 1 January 2024**, table 2903: Instituto Nacional de Estadística ([INE](https://www.ine.es/jaxiT3/Tabla.htm?t=2903)), reused under the INE [legal notice](https://www.ine.es/aviso_legal) with attribution, accessed 17 November 2026.
-   Death toll: Government of Spain, [DANA monitoring data of 24 November 2024](https://www.lamoncloa.gob.es/info-dana/Paginas/2024/241124-datos-seguimiento-actuaciones-gobierno.aspx), accessed 17 November 2026.
-   Code: [`flood_exposure.py`](https://www.technicalgis.com/code/flood-damage-exposure-population-python/), tested with Python 3.12.0, duckdb 2.0.0, geopandas 1.2.0, pyogrio 0.13.0, shapely 2.2.0, rasterio 1.5.2, numpy 2.5.5, pandas 3.1.1 and matplotlib 3.11.2.

## Key terms

- **Exposure**: The people, buildings and infrastructure located in a hazard zone. Exposure is not damage: a building can be in the flood and come through unharmed.
- **Damage grading**: A Copernicus EMS product in which image analysts mark each affected building and road as possibly damaged, damaged or destroyed from very high resolution imagery taken after the event.
- **Dasymetric mapping**: Redistributing a count from coarse units, such as 100 m grid cells, to finer ones, such as buildings, using ancillary data like floor area.
- **GHS-POP**: The Global Human Settlement Layer population grid from the European Commission's Joint Research Centre: residents per 100 m cell, made by spreading census counts over built-up volume.
- **Padrón**: Spain's municipal register of residents. INE publishes the official population of every municipality on 1 January each year.

## Data for this tutorial

-   [Copernicus EMS rapid mapping](https://www.technicalgis.com/data-sources/#src-copernicus-ems-mapping) · Activation EMSR773, AOI03 Horta Sud: delineation and grading products
-   [Overture Maps](https://www.technicalgis.com/data-sources/#src-overture-maps) · Building footprints with subtype and number of floors, queried with DuckDB
-   [Global Human Settlement Layer](https://www.technicalgis.com/data-sources/#src-global-human-settlement-layer) · GHS-POP E2025 R2023A, 100 m, Mollweide
-   [WorldPop](https://www.technicalgis.com/data-sources/#src-worldpop) · Spain 2024 constrained population, R2025A, 3 arcseconds
-   [Eurostat GISCO](https://www.technicalgis.com/data-sources/#src-eurostat-gisco) · Local administrative units (LAU) 2024: municipal boundaries
-   [Instituto Nacional de Estadística](https://www.technicalgis.com/data-sources/spain/#src-instituto-nacional-de-estadistica) · Padrón municipal population on 1 January 2024 (table 2903), read from the INE JSON API

Licences and formats for each source are listed in the [GIS data sources catalogue](https://www.technicalgis.com/data-sources/).

[← Part 2 Satellite flood mapping with Sentinel-1 and Sentinel-2: the Valencia floods of October 2024](https://www.technicalgis.com/tutorials/satellite-flood-mapping-sentinel-1-sentinel-2/)

---

Source: https://www.technicalgis.com/tutorials/flood-damage-exposure-population-python/
