eduaguilera/whep

scrape_faostat.R still hand-copies seven ISO3 codes the crosswalk already publishes (#421 says otherwise)

开放

#640 创建于 2026年8月7日

 (2 条评论) (0 个反应) (0 位负责人)R (3 个派生)auto 404
area:data-ioarea:regionsbuggood first issuehelp wantedmechanicalno-data-neededpriority:low

仓库指标

星标
 (1 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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

  1. 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.
  2. Sudan. The crosswalk sends the bare name to SDN, but area_code 206 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.

贡献者指南