# ZRR / FRR commune data: sources and transformations

Assembled 2026-10-03. Every value comes from a file downloaded from the URL
given below. The raw downloads were kept in `raw/`, which is not committed. The
xlsx files were read from their zip and XML parts, not converted by hand. The
`urssaf_commune_jobs.csv` transform is described in section 2.

| File | Rows | Content |
|---|---|---|
| `zrr_status.csv` | 34,875 communes | ZRR 2014-17, ZRR 2017, communes leaving in 2017, FRR 2024/25, in COG 2025 |
| `urssaf_commune_jobs.csv` | 673,040 = 33,652 communes x 20 years | private-sector employer establishments and employees on 31 December, 2006-2025, COG 2025 |
| `evaluations.md` (+ `eval/`) | - | published ZRR evaluations with verbatim quotes |
| `epci_2017.csv` | 1,244 EPCIs | the two 2017 classification criteria by metropolitan EPCI, rebuilt (section 7) |
| `commune_epci_2017.csv` | 34,763 links of 34,741 communes | COG 2025 communes to their EPCI of 1 January 2017 (section 7) |
| `rdd.csv` | 492 | results of `analysis/zrr_rdd.ml`, the jump at the 2017 thresholds (section 7) |
| `tax_expenditures_zrr.csv`, `social_exemptions_zrr.csv`, `tax_expenditures_notes.md` (+ `raw_te/`, `te_work/`) | 303 + 4 | tax-expenditure fiches (Voies et moyens tome II), plus social exemptions |

## Geography

**All commune files use COG 2025** (Code officiel géographique on 1 January
2025: 34,875 communes; Paris, Lyon and Marseille are whole communes, not
arrondissements). COG 2025 was chosen because:

- the FRR list is published in COG 2025;
- the Urssaf file is effectively in COG 2025. Its description says "Les
  nomenclatures des communes ... sont celles en vigueur au 1er janvier 2023",
  but every one of its codes except the 45 municipal arrondissements is a valid
  COG 2025 code. It contains codes created in 2024-2025, such as 12218, 14581,
  15031, 15035 (the 2025 split of Neussargues en Pinatelle), 49126, 60694 and
  69114. Projecting it to COG 2025 therefore only means adding the
  arrondissements together.

Older vintages are projected forward with the INSEE annual passage table:

- URL: https://www.insee.fr/fr/statistiques/fichier/7671867/table_passage_annuelle_2026.zip
- Page: https://www.insee.fr/fr/information/7671867, put online 19/03/2026,
  geography 2003-2026.
- Raw copy: `raw/table_passage_annuelle_2026.zip`. The `COM` sheet is
  converted to `raw/passage_2003_2026.csv`, and the merger, split and
  code-change lists to `raw/passage_*.csv`.

How statuses are projected:

- For each COG 2025 commune, the build collects the set of source-vintage codes
  that make it up and computes the share of them that hold a given status.
- A 0/1 column is 1 when the share is 1, 0 when it is 0, and **empty when the
  share is partial** (a commune nouvelle that merged classified and unclassified
  communes). The shares are in the `*_share` columns.
- The shares are unweighted counts of component communes, not population
  weights.

How many codes changed:

- 354 COG 2025 communes are mergers of 902 COG 2017 communes. Another 10 keep a
  single COG 2017 component under a different code.
- 836 COG 2025 communes are made of more than one COG 2014 commune.
- Three 2017 communes were later split: 14712, 15141 (in 2025) and 85084. Each
  resulting 2025 commune inherits the 2017 status of the parent.

## 1. `zrr_status.csv`

### Columns

| Column | Definition |
|---|---|
| `insee_code`, `commune_name` | COG 2025 code and name (INSEE passage table) |
| `cog_vintage` | 2025 |
| `zrr_2016` | 1 if every component was classified ZRR in the classification in force from 1 Jan 2014 to 30 June 2017 (arrêté of 10 July 2013 as completed by the arrêté of 30 July 2014) |
| `zrr_2017` | 1 if classified under the 2017 reform: status C (arrêté of 16 March 2017) or D (Decazeville communauté, added by the 2018 finance law and the arrêté of 22 Feb 2018) in the ANCT file |
| `left_2017` | 1 if a "commune sortante" that kept the benefits of classification: status A (3,063 communes in COG 2017; kept benefits to 30 June 2020, extended to end-2022 and then to 2023 per CGEDD 2022) or M (1,011 mountain communes) |
| `left_2017_mountain` | 1 for status M only |
| `frr_2024` | 1 if classified "FRR socle" or "FRR+" in the DGCL list of 10 July 2025. This list includes the 2025 additions applied retroactively from 1 July 2024 (arrêté of 14 April 2025) |
| `frr_plus_2025` | 1 if FRR+ (arrêté of 9 July 2025, in force retroactively from 1 Jan 2025, 4,466 communes per the FAQ; 4,456 in the list) |
| `frr_beneficiaire` | 1 if a former ZRR commune not classified FRR that receives FRR effects from 1 July 2024 to 31 Dec 2027 (LFI 2025 art. 99 IV; annexe 2 of the arrêté of 14 April 2025) |
| `zrr_2016_share`, `zrr_2017_share`, `left_2017_share` | share of component communes with the status |
| `zrr_2017_detail` | the set of ANCT detailed codes (C, D, A, M, P, NC) among the COG 2017 components |
| `frr_detail_2025` | the label as printed in the DGCL list |
| `n_codes_cog2014`, `n_codes_cog2017`, `codes_cog2017` | how the commune was composed in earlier vintages |
| `in_urssaf` | 1 if the commune appears in the Urssaf file (see section 2) |

### Counts in COG 2025

- `zrr_2016`: 14,027 classified, 20,813 not classified, 35 partial.
- `zrr_2017`: 13,629 classified, 21,216 not classified, 30 partial.
- `left_2017`: 3,999 (of which 985 mountain), 12 partial.
- `frr_2024`: 17,769 classified (13,313 socle + 4,456 FRR+), 20 partially classified.
- `frr_beneficiaire`: 2,134, plus 11 partial.

Transitions in COG 2025:

- 10,037 communes were ZRR in 2016 and stayed ZRR in 2017.
- 3,988 were ZRR in 2016 and left in 2017.
- 3,583 entered ZRR in 2017.
- 17,206 were never ZRR.

### Sources

**a) ZRR 2017 reform.** ANCT, "Zones de Revitalisation Rurale (ZRR)", data.gouv.fr dataset 5943d13588ee38742a95eb0c
(https://www.data.gouv.fr/datasets/zones-de-revitalisation-rurale-zrr).

- File: `diffusion-zonages-zrr-cog2021.xls`, 6,437,376 bytes, last modified 2021-09-07:
  https://static.data.gouv.fr/resources/zones-de-revitalisation-rurale-zrr/20210907-124104/diffusion-zonages-zrr-cog2021.xls
  (raw copy in `raw/`).
- Sheet "Classement ZRR (COG 2017)" is the source used. It is labelled "Source :
  ANCT, arrêté du 16 mars 2017, modifié par le décret du 22 février 2018" and
  has 35,416 communes. Its ZONAGE_ZRR codes are:
  - C 13,870
  - D 12
  - P 20 (partially classified; overseas and merged communes)
  - A 3,063
  - M 1,011
  - NC 17,440

  These counts match the Sénat report r19-041: 3,063 + 1,011 = 4,074 communes
  leaving.
- The file's documentation says "Le classement des communes en ZRR est valable
  jusqu'au 31 décembre 2022". The extension to 30 June 2024 and the switch to
  FRR are described in the FRR FAQ.
- Sheet "Classement ZRR (COG 2021)" (ANCT's own conversion) is used only as a
  cross-check. For every commune whose code is unchanged between 2021 and 2025,
  my projection reproduces ANCT's C, D, A, M, P and NC classes exactly:
  - C: 13,462
  - D: 12
  - A: 2,989
  - M: 973
  - NC: 17,055
  - P: 20
- **2018-2021 updates:** the only change after the arrêté of 16 March 2017 is
  status D (arrêté of 22 Feb 2018), and it is already in the sheet. I found no
  other national modifying list. The remaining 2018-2021 changes are
  re-expressions of the same classification in later COG vintages.

**b) ZRR before the reform (`zrr_2016`).** This is built from two sources.

1. **The arrêté of 10 July 2013.** It is the "2013" sheet of ANCT
   `diffusion-zonages-historique-zrr-2019.xls` (data.gouv resource
   0de7f39a-db4f-41b8-8409-2b2a55568e07, 28,111,360 bytes,
   https://static.data.gouv.fr/resources/zones-de-revitalisation-rurale-zrr/20201124-143142/diffusion-zonages-historique-zrr-2019.xls).
   The sheet is labelled "DATAR, arrêté du 10 juillet 2013 (modifié et rectifié
   jusqu'au 19 décembre 2013)", COG 2012.
   - The xls is larger than the 10 MB download limit of the fetch tool, so it
     could not be downloaded. The 14,294 "C - Classée" codes were read through
     data.gouv's tabular API instead:
     `https://tabular-api.data.gouv.fr/api/resources/0de7f39a-db4f-41b8-8409-2b2a55568e07/data/?Unnamed%3A%202__exact=C%20-%20Class%C3%A9e&columns=Champ%20%3A%20France%20enti%C3%A8re&page_size=200&page=1..72`.
     The result is in `raw/zrr2013_classees_cog2012.csv`, with the pages in
     `raw/zrr2013_pages/`.
   - Checks on this extraction:
     - the API reports total = 14,294, and 14,294 unique codes were obtained;
     - each page has 200 codes (94 on the last) in ascending order;
     - all codes exist in COG 2012;
     - a random spot check of 40 listed codes and 40 gap codes against the API
       matched.
   - The sheet's other values are "NC - non classée" (22,406) and two header rows.
2. **The arrêté of 30 July 2014.** "Arrêté du 30 juillet 2014 constatant le
   classement de communes en zone de revitalisation rurale", Légifrance
   JORFTEXT000029314044 (https://www.legifrance.gouv.fr/jorf/id/JORFTEXT000029314044).
   - Its Article 1 says the communes listed in the annexes of the arrêté of 10
     July 2013 and of this arrêté are classified. Article 2 makes the
     classification effective on 1 January 2014.
   - The annex lists 401 communes with their INSEE codes. They are in
     `raw/arrete_20140730_annexe_raw.txt`.
   - The annex was read from the Légifrance HTML department by department.
     401 matches the count in AN report 2251 ("entrée de 401 communes",
     14,691 in total). **All 401 code and name pairs match COG 2014 names
     exactly.**

The 2013 list is mapped from COG 2012 to COG 2014 (14,289 codes), and the 401
additions are added, giving **14,690 communes in COG 2014**. The official
total is 14,691; the difference of one comes from a 2012-2014 merger.

Validation against Sénat report r19-041 (2019), which counts 10,211 communes
remaining, 3,679 entering and 4,074 leaving in 2017. In COG 2017 my build
gives:

- C+D 2017 communes with a 2014-ZRR component: 10,210.
- Entrants: 3,672. The Sénat's 13,890 classified includes P and D communes
  counted slightly differently.
- **All 4,074 A+M communes are in my 2014 list, and every 2014-ZRR commune is
  either C, D, A, M or P in 2017.**

**c) FRR.** DGCL, "Liste des communes zonées FRR et FRR+ (07/25)". It is linked
from
https://www.collectivites-locales.gouv.fr/animer-les-territoires/cohesion-territoriale-et-lamenagement-du-territoire/la-cohesion-territoriale/les-ruralites/le-plan-france-ruralites.

- File: https://www.collectivites-locales.gouv.fr/files/files/3.%20Animer%20les%20territoires/5.%20La%20coh%C3%A9sion%20territoriale%20et%20l'am%C3%A9nagement%20du%20territoire/Liste%20communes%20FRR_juillet2025.xlsx
  (raw copy `raw/Liste_communes_FRR_juillet2025.xlsx`).
- Its one sheet is "Commune classées FRR et FRR+", with the column "Classement
  FRR et FRR+ au 10 juillet 2025". It has 34,875 rows, which equals COG 2025;
  the workbook path also says "FRR socle COG25".
- Values:
  - Non classée: 14,941
  - FRR socle: 13,313
  - FRR+: 4,456
  - FRR bénéficiaire: 2,134
  - Classée FRR partiellement: 20
  - FRR bénéficiaire partiellement: 11
- Definitions and dates come from the DGCL "FAQ FRR (MAJ juillet 2025)":
  https://www.collectivites-locales.gouv.fr/files/files/3.%20Animer%20les%20territoires/5.%20La%20coh%C3%A9sion%20territoriale%20et%20l'am%C3%A9nagement%20du%20territoire/FAQ%20FRR_MAJ%20juillet2025.pdf
  (`raw/FAQ_FRR_juillet2025.pdf/.txt`). The FAQ gives:
  - arrêté of 19 June 2024: 17,717 communes, in force 1 July 2024;
  - arrêté of 14 April 2025: new FRR socle communes (annexe 1) and FRR
    bénéficiaires (annexe 2), retroactive to 1 July 2024;
  - arrêté of 9 July 2025: FRR+, 4,466 communes, retroactive to 1 January 2025.
- **Not obtained:** the original list of 19 June 2024 as a file. A May 2025
  version linked from ecologie.gouv.fr
  (`https://www.collectivites-locales.gouv.fr/files/Cohésion%20territoriale/Liste communes FRR_mai2025.xlsx`)
  returns 404. `frr_2024` therefore reflects the classification as amended in
  2025, not only the communes classified in June 2024. The difference is about
  52 communes (17,769 − 17,717).

## 2. `urssaf_commune_jobs.csv`

The source is Urssaf open data, "Nombre d'établissements employeurs et
effectifs salariés du secteur privé, par commune x APE (au 31/12 depuis
2006)".

- Dataset id: `etablissements-et-effectifs-salaries-au-niveau-commune-x-ape-last`
  (https://open.urssaf.fr/explore/dataset/etablissements-et-effectifs-salaries-au-niveau-commune-x-ape-last/).
- 1,227,408 commune x APE rows. Modified 2026-05-29, issued 2026-05-28.
- Licence ODbL. The catalogue metadata is in `raw/urssaf_catalog_meta.xlsx`.

How it was downloaded:

- The file is aggregated over APE on the server, through the Opendatasoft
  export API with `group_by`. There are two requests, one for establishments and
  one for employees. Raw copies are in `raw/urssaf_commune_etab_grouped.xlsx`
  and `raw/urssaf_commune_eff_grouped.xlsx`, each with 33,696 codes.
- Establishments request:
  `https://open.urssaf.fr/api/explore/v2.1/catalog/datasets/etablissements-et-effectifs-salaries-au-niveau-commune-x-ape-last/exports/xlsx?select=code_commune,intitule_commune,sum(nombre_d_etablissements_2006)+as+e2006,...,sum(nombre_d_etablissements_2025)+as+e2025,count(code_ape)+as+n&group_by=code_commune,intitule_commune&limit=-1`
- Employees request: the same, with `sum(effectifs_salaries_YYYY)+as+sYYYY`.

Definitions, verbatim from the dataset description:

- "Nombre d'établissements employeurs et effectifs salariés en fin d'année".
  Champ: "établissements employeurs du secteur privé, régime général".
- Establishments = "comptes ayant une déclaration de masse salariale au dernier
  mois de l'année".
- "Les effectifs salariés sont mesurés en fin d'année", that is, a **31
  December headcount, not an annual average**.
- "A compter de la publication du mois de juin 2023, les apprentis sont inclus
  dans le dénombrement des effectifs salariés" (for the whole series, as
  re-published).
- The DSN switch-over was completed in June 2021, with possible level
  revisions.
- Temporary agency workers are counted at the agency's establishment.

Transformations:

- In the raw rows a commune x APE x year cell is empty when there was no
  establishment. An all-empty sum is returned as 0.0 and written as 0.
- The 45 arrondissements are summed into 75056 Paris, 13055 Marseille and
  69123 Lyon.
- The result is reshaped to long format: `insee_code`, `year`,
  `establishments`, `employees`. It has 33,652 COG 2025 communes x 2006-2025.

Check: the commune sum of employees equals the Urssaf France-level dataset
(`nombre-detablissements-employeurs-et-effectifs-salaries-du-secteur-prive-france-`,
`raw/urssaf_france_totals.xlsx`) to within 0.01%. For example, 2025 gives
19,971,155 against 19,972,449, and 2006 gives 17,775,848 against 17,776,332.

Missing communes: 1,223 COG 2025 communes are absent from the Urssaf file
(`in_urssaf = 0`); 821 of them were ZRR-classified in 2017. They have no
private-sector employer with payroll on 31 December in any year from 2006 to
2025, so treating them as 0 is an inference, not a published value. No
statistical-secrecy suppression is documented for this dataset.

## 3. Evaluations

See `evaluations.md` for the full references, URLs and verbatim quotes, and
`eval/` for the PDFs and their text. It covers:

- Behaghel, Lorenceau and Quantin (J. Public Econ. 2015, abstract only);
- Lorenceau (Économie et Statistique 2009);
- the joint inspection report CGEDD/IGA/CGAAER/IGAS (2014);
- AN report 2251 (Calmette and Vigier, 2014);
- Sénat report r19-041 (2019);
- the report to the Prime Minister (Blanc, Delcros, Barrot and Espagnac, CGEDD 2022).

## 4. Tax expenditures

See `tax_expenditures_notes.md`. It uses the Voies et moyens tome II PLF
2010-2018 and 2024-2026. Every row has its URL and PDF page. PLF 2019-2023 and
2027 were not obtained.

## 5. Commune panels and covariates from the `house` project

Three files come from the `france.db` database that `~/git/house` (the
`carucate` pipeline) builds from primary open data. They were exported with
`sqlite3` on 2026-10-03, unchanged apart from the selection of columns:

- `covariates.csv`: `communes.code`, `dept`, `lat`, `lon` (INSEE commune
  metadata, Code officiel géographique, as loaded by `house`), joined to the
  2016 row of `income_tax` (`households`, `reference_income`).
- `ircom.csv`: the `income_tax` table, 2003-2024 by year the income was
  earned: tax households and their total fiscal reference income per commune.
  Source: DGFiP, "L'impôt sur le revenu par collectivité territoriale (IRCOM)",
  data.gouv.fr, Licence Ouverte; `house` assembles the yearly workbooks into
  one series (`lib/pipeline/income.ml`). Communes where DGFiP suppresses small
  counts are absent for those years.
- `vital.csv`: the `vital` table, births and deaths per commune and year,
  2008-2025. Source: INSEE état civil, as derived by `house`
  (`lib/pipeline/vital.ml`).

Geography: `house` uses the current COG; codes that differ from COG 2025 drop
out of the join rather than being remapped.

## 6. Outcomes for the programmes' other aims

Added 2026-10-15, read by `analysis/commune.ml` for the ZRR and the
place-based programmes (`analysis/places.ml`). Neither file is read by the
site build; the results are.

- `census.csv`: population, labour force aged 15-64 (`ACT1564`), jobs at the
  place of work (`EMPLT`) and those jobs in industry (`EMPLT_INDUS`), 2015
  and 2021, by commune. Source: Insee, recensement de la population 2021,
  "Évolution et structure de la population"
  (https://www.insee.fr/fr/statistiques/fichier/8201904/base-cc-evol-struct-pop-2021_csv.zip)
  and "Emploi - population active"
  (https://www.insee.fr/fr/statistiques/fichier/8202916/base-cc-emploi-pop-active-2021_csv.zip),
  Licence Ouverte. The CSVs were read from the copies the `house` project
  (the `carucate` pipeline) downloaded into `pipeline/data/raw/insee/`, with
  `dune exec data/zrr/build/census.exe -- base-cc-evol-struct-pop-2021.CSV
  base-cc-emploi-pop-active-2021.CSV data/zrr/census.csv`. Counts are Insee's
  weighted estimates; three communes with no 2021 population are empty. The
  files are in the geography Insee published them in (34,963 codes); codes
  that differ from COG 2025 drop out of the join.
- `land.csv`: land taken from natural, agricultural and forest land each
  year, for housing, for economic activity and in all, in m², by commune.
  Source: CEREMA, "Consommation d'espaces naturels, agricoles et forestiers"
  from the fichiers fonciers, data.gouv.fr dataset 6a01b9280dd2d45907e5fc61
  (the millésime published in July 2026), Licence Ouverte. Year Y is the
  land consumed between 1 January Y-1 and 1 January Y (`naf11art12` is
  2012). Exported on 2026-10-15 from the `artificialisation` table of
  `france.db`, which `house` assembles from that file, with
  `sqlite3 -readonly -csv -header france.db "select code as insee_code, year,
  cast(habitat_m2 as integer) as housing_m2, cast(activity_m2 as integer) as
  activity_m2, cast(naf_m2 as integer) as total_m2 from artificialisation
  order by code, year"`.

- The vacancy and price outcomes are read from `data/places/`: `lovac.csv`
  (vacant private dwellings, 2019-2025), `dvf.csv` (median price per m² of
  dwellings sold, 2016-2021) and `dvf_etalab.csv` (the same from Etalab's
  statistics, 2021-2025), each documented, with the command that builds it,
  in `data/places/SOURCES.md`.

Net migration is computed in `analysis/commune.ml` from `census.csv` and
`vital.csv`: the change in population from 1 January 2015 to 1 January 2021
less births and deaths in 2015-2020.

## 7. The 2017 thresholds by EPCI

Added 2026-10-15, read by `analysis/zrr_rdd.ml`. Built with
`dune exec data/zrr/build/epci.exe -- EXTRACTS_DIR data/zrr`, where
`EXTRACTS_DIR` holds the CSV extracts unzipped from
`raw/epci_2017_extracts.zip`.

### The rule

CGI art. 1465 A II, as rewritten by art. 45 of loi n° 2015-1786 (LFR 2015)
and in force for the classification of 1 July 2017 (BOFiP
BOI-IF-CFE-10-30-40-40-20170906, §§ 30-50,
https://bofip.impots.gouv.fr/bofip/4219-PGP.html/identifiant=BOI-IF-CFE-10-30-40-40-20170906;
Légifrance, art. 1465 A, https://www.legifrance.gouv.fr/codes/article_lc/LEGIARTI000048864264/2024-05-24/):

- the communes of an EPCI à fiscalité propre are classified when "sa densité
  de population est inférieure ou égale à la densité médiane nationale des
  EPCI à fiscalité propre métropolitains" and "son revenu fiscal par unité de
  consommation médian est inférieur ou égal à la médiane des revenus
  médians";
- the data are "établies par l'INSEE" from those available "au 1er janvier de
  l'année de classement", and the population is "la population municipale
  définie à l'article R. 2151-1 du CGCT";
- communes in no EPCI (CGCT L. 5210-1-1 V, the islands) are judged alone;
  Guyane and the zone spéciale d'action rurale of La Réunion are classified
  by law. Both are left out here.
- The population-decline clause (a fall of 30% over four decades) was added
  by art. 27 of the LFI 2018; it classified only Decazeville Communauté
  (status D, arrêté of 22 February 2018).

The CGET's departmental notes of 17 February 2017 ("Réforme des zones de
revitalisation rurale (ZRR) pour le Loiret", signed by its rural desk, raw
copy `raw/cget_zrr_2017_loiret.pdf`, fetched from
https://chilleurs-aux-bois.fr/wp-content/uploads/sites/21/2018/01/FicheDep_45_Loiret-couleur_Copy0354.pdf)
say the calculation used "les périmètres d'EPCI arrêtés au premier janvier
2017" and "les données (population et revenus fiscaux) ... disponibles au
premier janvier 2017", and give the two medians: "ce seuil est de 63
hab/km2" and "ce seuil est de 19111 €". No file of the CGET's values by
EPCI was found: the ANCT's data.gouv.fr dataset 5943d13588ee38742a95eb0c
holds only the commune lists, and the Observatoire des territoires refused
the fetch (HTTP 403).

The vintages that were available on 1 January 2017 are therefore the 2014
population légale (in force from 1 January 2017) and FiLoSoFi 2013
(published by Insee on 28 December 2016; FiLoSoFi 2014 came out on 29
September 2017). The Loiret note confirms FiLoSoFi 2013: for the two EPCIs
of 2017 that are whole EPCIs of 2014, its medians (€20,812 and €22,950) are
Insee's FiLoSoFi 2013 figures to the euro.

### Inputs

Each Insee and ANCT workbook is an `.xls` (BIFF) file, which the
monorepo's `xlsx` library does not read. The sheets were converted to CSV
with Python's `xlrd` 1.2.0, column by column and without any other change
(integral numbers written without a decimal point), by:

```python
import sys, csv, xlrd
book, sheet, hdr, out, cols = sys.argv[1], sys.argv[2], int(sys.argv[3]), sys.argv[4], sys.argv[5:]
s = xlrd.open_workbook(book, on_demand=True).sheet_by_name(sheet)
head = [str(v).strip() for v in s.row_values(hdr)]
idx = [head.index(c) for c in cols]
def cell(v):
    if isinstance(v, float): return repr(int(v)) if v == int(v) else repr(v)
    return str(v).strip()
with open(out, 'w', newline='') as f:
    w = csv.writer(f, lineterminator='\n'); w.writerow(cols)
    for r in range(hdr + 1, s.nrows): w.writerow([cell(s.row_values(r)[i]) for i in idx])
```

The extracts are in `raw/epci_2017_extracts.zip` (not committed; SHA-256
`9efda961ea214c18f1af9243360afc7d8ad7b1cdfe03f2097b0257c6cc2ccbd5`):

| Extract | Source (all downloaded 2026-10-15) | Sheet, header row, columns | Rows |
|---|---|---|---|
| `epci_2017_composition.csv` | Insee, "Intercommunalité – Métropole au 1er janvier 2017", https://www.insee.fr/fr/statistiques/fichier/2510634/Intercommunalite_Metropole_au_01-01-2017.zip (put online 22/09/2017, geography 1 January 2017) | `Composition_communale`, 5, `CODGEO LIBGEO EPCI LIBEPCI DEP` | 35,416 communes, 1,268 EPCIs |
| `epci_2014_composition.csv` | Insee, EPCI au 1er janvier 2014, https://www.insee.fr/fr/statistiques/fichier/2510634/epci-au-01-01-2014.zip (communes in COG 2013) | `Composition communale des EPCI`, 1, `CODGEO EPCI` | 36,664 |
| `pop2014_cog2016.csv` | Insee, "Évolution et structure de la population en 2014", https://www.insee.fr/fr/statistiques/fichier/2862200/base-cc-evol-struct-pop-2014.zip (geography 1 January 2016) | `COM_2014`, 5, `CODGEO P14_POP` | 35,868 |
| `superf_cog2017.csv` | Insee, "Séries historiques en 2015", https://www.insee.fr/fr/statistiques/fichier/3565661/base-cc-serie-historique-2015.zip (geography 1 January 2017) | `COM_2015`, 5, `CODGEO P15_POP SUPERF` | 35,399 |
| `filo2013_dec_com.csv` | Insee, FiLoSoFi 2013, "Structure et distribution des revenus", https://www.insee.fr/fr/statistiques/fichier/2388413/indic-struct-distrib-revenu-2013-COMMUNES.zip, `FILO_DEC_COM.xls` (geography 1 January 2014) | `ENSEMBLE`, 5, `CODGEO NBMEN13 NBPERS13 Q213 D113 D213 D313 D413 D613 D713 D813 D913` | 32,991 |
| `filo2013_dec_epci.csv` | the same, https://www.insee.fr/fr/statistiques/fichier/2388413/indic-struct-distrib-revenu-2013-SUPRA.zip, `indic-struct-distrib-revenu-2013-EPCI.zip`, `FILO_DEC_EPCI.xls` (EPCIs of 1 January 2014) | `ENSEMBLE`, 5, `CODGEO LIBGEO NBMEN13 NBPERS13 Q213 D113 ... D913` | 2,135 |
| `passage.csv` | Insee passage table of section "Geography" above, `table_passage_annuelle_2026.xlsx` | `COM`, 5, `NIVGEO CODGEO_2013 CODGEO_2014 CODGEO_2016 CODGEO_2017 CODGEO_2025` | 36,760 |
| `anct_zrr_cog2017.csv` | ANCT `diffusion-zonages-zrr-cog2021.xls` of section 1 a (6,437,376 bytes, raw copy zipped as `raw/diffusion-zonages-zrr-cog2021.zip`) | `Classement ZRR (COG 2017)`, 5, `CODGEO LIBGEO ZONAGE_ZRR` | 35,416 |

### How the criteria are rebuilt

- **Population**: `P14_POP` (population municipale 2014) of the 2016
  communes, carried to the communes of 2017 through the passage table
  (communes nouvelles of 1 January 2017 sum their parts), and summed by EPCI.
- **Area**: `SUPERF` (km²) of the 2017 communes, summed by EPCI. Density is
  population over area.
- **Median income per consumption unit**: Insee published FiLoSoFi 2013 for
  the EPCIs of 2014; the map of 2017 merged most of them. For each EPCI of
  2017, each EPCI of 2014 whose communes all went into it enters whole, with
  its nine deciles and its persons; an EPCI of 2014 split between EPCIs of
  2017 enters through its communes, each with its deciles where Insee gives
  them, or with its median and the shape (deciles over median) of its EPCI
  of 2014 otherwise. Where Insee gives an EPCI only a median, the shape is
  the persons-weighted average shape of the EPCIs of 2014. The median of the
  persons-weighted mixture is found by bisection, the share below an income
  being linear in log income between deciles. 605 EPCIs of 2017 are a single
  EPCI of 2014 (`income_source` = `insee`, Insee's own figure); 639 are
  mixtures.
- **Metropolitan EPCIs**: those of the composition file outside the
  overseas départements, without the communes in no EPCI (`ZZZZZZZZZ`):
  1,244 of the file's 1,267 EPCIs (the other 23 are overseas).

### Checks

- Population 64,006,187 and area 543,784 km² over the 1,244 EPCIs; the CGET
  note gives 64,027,784 and 543,940 for metropolitan France, the difference
  being the islands outside any EPCI.
- The median of the densities computed here is 63.19 (CGET: 63); the median
  of the medians is €19,107 (CGET: €19,111).
- The Loiret note's six EPCIs: densities 28, 77, 60, 37, 73, 34 against
  27.55, 77.28, 59.52, 37.41, 72.82, 34.45 here; medians €20,812, €22,950,
  €19,490, €19,618, €21,656, €19,009 against €20,812, €22,950, €19,490,
  €19,640, €21,692, €19,011 (the first two Insee's figures, the others
  mixtures, off by €0 to €36). Linear rather than log interpolation between
  deciles was off by €21 to €62.
- **Agreement with the arrêté**: `eligible` (both conditions on the values
  here) and `classified` (the ANCT's status C or D for at least half of the
  EPCI's communes; in fact every EPCI is all or nothing) agree for 1,240 of
  the 1,244 EPCIs (99.7%). The four others: Decazeville Communauté (density
  104, classified in 2018 by the decline clause); CC du Canton de Vatan et
  de Champagne Berrichonne (€19,135 here, classified) and CC Porte
  d'Aquitaine en Pays de Serres (€19,041 here, not classified), both
  mixtures within €30 of the threshold; and CC Pontivy Communauté (density
  63.05, €19,106 here, not classified).

### The density threshold

The arrêté classifies EPCIs whose density computed here is 63.11, 63.32,
63.37 and 63.39 and that meet the income condition, and no EPCI from 64.05;
no metropolitan EPCI lies between 63.39 and 63.78. This fits a density
compared once rounded to the unit with the published 63, or a median
between 63.39 and 64.05 on the CGET's own figures; both classify the same
EPCIs. `density_cutoff` is 63.5 and `income_cutoff` €19,111.

### `epci_2017.csv` columns

| Column | Definition |
|---|---|
| `epci`, `name`, `communes` | SIREN code, name and number of communes on 1 January 2017 |
| `population`, `area_km2`, `density` | population municipale 2014, area, inhabitants per km² |
| `median_income`, `income_source` | median declared income per consumption unit, FiLoSoFi 2013, € a year; `insee` or `mixture` as above |
| `density_margin`, `income_margin` | log of the threshold over the value (log 63.5/density, log 19,111/income): at or above zero, the condition holds |
| `eligible` | 1 if both margins are at or above zero |
| `classified_share`, `classified` | share of the EPCI's communes with ANCT status C or D (arrêté of 16 March 2017 and of 22 February 2018), and 1 if at least half |

### `commune_epci_2017.csv` columns

`insee_code` (COG 2025), `epci` (of 1 January 2017), `share`: the share of
the commune's COG 2017 components in that EPCI, from the passage table. 22
communes nouvelles span two EPCIs of 2017 (44 rows with a share below 1);
`analysis/zrr_rdd.ml` uses only the links with share 1. A COG 2017 commune
split later gives each successor its EPCI with share 1.

### `rdd.csv` columns

One row per design, running variable, outcome, year and bandwidth, written
by `analysis/zrr_rdd.ml`:

| Column | Definition |
|---|---|
| `design` | `first_stage` (the share of an EPCI's communes classified), `unaffected` (the same for EPCIs failing the other condition, where nothing should jump), `entry` (communes not classified before July 2017), `exit` (communes classified in 2014-2017), and `entry_placebo` and `exit_placebo` (the same at a false threshold, the median of one side, using that side only) |
| `running` | `density` (among EPCIs meeting the income condition) or `income` (among those meeting the density condition) |
| `outcome`, `year` | the change in the log of the EPCI's summed count from 2016 to `year` (`jobs`, `establishments`: Urssaf; `households`: IRCOM; `income`: IRCOM reference income per tax household) or from the 2015 to the 2021 census (`population`, `active`, `workplace_jobs`, `industry_jobs`); a year before the base is a pre-trend. Only communes reporting both years are summed. `classified` for the classification rows |
| `cutoff` | the threshold in inhabitants per km² or euros |
| `bandwidth`, `rule` | half-width on the margin scale (log); `ik` is Imbens and Kalyanaraman's for jobs 2016-2019 of the design, `half` and `double` its half and double |
| `jump`, `se`, `ci_low`, `ci_high` | local linear jump (classified side minus the other), robust standard error, 95% interval |
| `left`, `right` | EPCIs within the bandwidth on the unclassified and classified side |
| `density_check`, `density_se` | McCrary's log ratio of the density of EPCIs at the threshold, classified side over the other, and its standard error |

## 8. `sirene_market.csv`: market-sector establishment creations and stock, commune × year, 2015-2025

The creation rate of the State's indicator MVA-7-1 (creations of the year
over the stock), approximated with Sirene establishments.

- **Source:** OpenDataSoft `economicref-france-sirene-v3`, a copy of the Insee
  Sirene stock of establishments (43,896,818 records, dataset modified
  2026-08-15), counted by the server on 2026-10-16 with the CSV export
  `https://public.opendatasoft.com/api/explore/v2.1/catalog/datasets/economicref-france-sirene-v3/exports/csv`
  (URL-encoded parameters):
  - creations: `select=count(*) as n`,
    `where=datecreationetablissement>=date'2015-01-01' and datecreationetablissement<date'2026-01-01' and <B-N>`,
    `group_by=codecommuneetablissement,year(datecreationetablissement) as year`
    (1,405,698 bytes, 345,393 rows);
  - stock on 1 January of each year Y from 2015 to 2025: `select=count(*) as n`,
    `where=datecreationetablissement<date'Y-01-01' and (etatadministratifetablissement='Actif' or datedebutetablissement>=date'Y-01-01') and <B-N>`,
    `group_by=codecommuneetablissement` (about 146 kB and 35,070 rows each);
  - `<B-N>` is `nomenclatureactiviteprincipaleetablissement='NAFRev2' and not
    (startswith(activiteprincipaleetablissement,'01') or ... '03', '84' to '88',
    '90' to '99')`, the NAF sections B to N the indicator covers (the API
    refuses a range comparison on the activity code).
- **Stock:** an establishment is open on 1 January Y when it was created
  before Y and is still active, or its current period, which for a closed
  establishment starts on its closure, starts on or after Y. The closure date
  field is left aside: 2,551,598 closed establishments have none, while every
  filled one equals the start of the current period. 517,794 closed
  establishments have no date at all and count as closed before 2015. 429
  establishments of the 2022 stock have an activity in an older nomenclature
  and are left out with the filter.
- **Built by** `dune exec data/places/build/market.exe -- data/zrr/zrr_status.csv
  data/zrr/raw/table_passage_annuelle_2026.zip data/zrr/sirene_market.csv
  CREATIONS.csv 2015=STOCK_2015.csv ...`, with the geography of
  `data/places/sirene_creations.csv` (arrondissements summed, codes mapped to
  COG 2025 through the Insee passage table, then `zrr_status.csv`; blank
  communes, the COM and unknown codes left out: 237,923 creations over
  2015-2025). The raw counts are not kept in the repository.
- **Columns:** `insee_code` (COG 2025), `year`, `creations` (in the year),
  `stock` (on 1 January). 383,332 rows.
- **Totals:** creations 802,732 in 2015, 1,418,920 in 2022, 1,566,539 in 2025;
  stock 7,134,964 on 1 January 2015, 9,687,761 in 2022, 11,029,240 in 2025.
  The national rate for 2022 creations is 14.7%, below Insee's 20.2% for
  enterprises (RAP 2024): a transfer to a new address is an establishment
  creation, and the stock keeps establishments that stopped trading without
  closing.

## 9. `afr_2022.csv`: the communes of the AFR zoning 2022-2027, COG 2025

The zone of the State's indicator MVA-7-1 is AFR or ZRR/FRR.

- **Source:** ANCT, « Zones d'Aide à finalité régionale (AFR) », data.gouv.fr
  dataset `5943d4c188ee38742a95eb0d` (the zoning of décret n° 2022-968 du 30
  juin 2022, 2022-2027), resource « Liste des communes bénéficiaires (COG
  2022) »,
  `https://static.data.gouv.fr/resources/zones-daide-a-finalite-regionale-afr/20221121-151930/liste-afr-com2022-20221121.csv`
  (298,949 bytes, 7,298 communes: 7,288 « intégralement », 10 « partiellement »,
  zoned in part by IRIS or canton), with its metadata
  `liste-afr-metadata.pdf` (owner DGCL, Licence Ouverte 2.0), both downloaded
  on 2026-10-16 and not kept in the repository.
- **Built by** `dune exec data/places/build/afr.exe -- liste-afr-com2022.csv
  data/zrr/zrr_status.csv data/zrr/raw/table_passage_annuelle_2026.zip
  data/zrr/afr_2022.csv`: codes go to COG 2025 as for
  `data/places/sirene_creations.csv`. A COG 2025 commune is « intégralement »
  when every COG 2022 commune it was made of, according to the passage table,
  is wholly zoned, and « partiellement » otherwise.
- **Columns:** `insee_code` (COG 2025), `afr_2022`, `source_codes`. 7,292 rows,
  23 « partiellement » (the 10 of the list and 13 communes nouvelles that merged
  zoned and unzoned communes); Saint-Martin (97801) is outside the COG and left
  out.
