scrape_faostat.R still hand-copies seven ISO3 codes the crosswalk already publishes (#421 says otherwise)
#640 aperta il 7 ago 2026
Metriche repository
- Star
- (1 stella)
- Metriche merge PR
- (Metriche PR in attesa)
Descrizione
Spun out of #421 while doing the EU28 half in #639, so this is not scope creep
on that PR — it is the one line of #421's table whose "fixed" verdict does not
hold on main.
What #421 claims, and what is actually there
#421's sweep table records R/scrape_faostat.R as fixed: "All seven ISO3
patches agreed with area_iso3c, so they were a hand-maintained copy of
published data. Now read from the crosswalk."
That fix exists only on the unmerged polities-integration branch (the commit
before 9f55abfb). On main today, .populate_iso3_code() still carries all
seven by hand:
df[df$area == "China, mainland", "ISO3_CODE"] <- "CHN"
df[df$area == "Türkiye", "ISO3_CODE"] <- "TUR"
df[df$area == "Netherlands (Kingdom of the)", "ISO3_CODE"] <- "NLD"
df[df$area == "Sudan", "ISO3_CODE"] <- "SDN"
df[df$area == "South Sudan", "ISO3_CODE"] <- "SSD"
df[df$area == "Czechia", "ISO3_CODE"] <- "CZE"
df[df$area == "Lao People's Democratic Republic", "ISO3_CODE"] <- "LAO"
They sit on top of .match_fao_area_to_iso3(), which resolves against
FAOSTAT::FAOcountryProfile — a third party's name table — rather than against
this package's own published FAOSTAT-name crosswalk.
The agreement claim does verify
Driving the real whep::regions_full on main, FAOSTAT_name -> iso3c:
| FAOSTAT name | hand patch | regions_full crosswalk |
|---|---|---|
| China, mainland | CHN | CHN |
| Türkiye | TUR | TUR |
| Netherlands (Kingdom of the) | NLD | NLD |
| Sudan | SDN | SDN |
| South Sudan | SSD | SSD |
| Czechia | CZE | CZE |
| Lao People's Democratic Republic | LAO | LAO |
Seven for seven, no disagreements. So the list is a private copy of published data, exactly as #421 says.
Two things to check before substituting
- The apostrophe. The Lao entry only resolves when the apostrophe is the
ASCII
'. With the typographic’the crosswalk returns nothing. Whichever FAOSTAT delivers, a substitution has to normalise rather than assume, or the patch silently stops applying. Sudan. The crosswalk sends the bare name toSDN, butarea_code206 is Sudan (former), i.e. Sudan + South Sudan pre-2011. The hand patch and the crosswalk agree on the string; whether either is right for pre-2011 rows is a separate question and should be answered, not inherited.
Neither is a reason to keep the list. Both are reasons the substitution needs a test that fails without it, not just a green suite.
Suggested shape
Read the seven from regions_full (or from resolve_polity_label(), which is
what #573 used for the same class of problem in
inst/scripts/prepare_spatialize_all.R), keep .match_fao_area_to_iso3() as
the general path, and assert in test_scrape_faostat.R that every name the
crosswalk resolves comes back with the ISO3 the hand list used to produce —
pinned by identity, so the relationship is documented rather than rediscovered
a third time.
Verifiable from a clone: regions_full is package data and the check needs no
network, so this is no-data-needed.
Part of the polity migration epic #458.