Bolivia Municipalities on Wikipedia: Coverage by Language

Author

Carwil Bjork-James

Overview

This document maps the completeness of Wikipedia coverage for Bolivia’s 336 official municipalities across six Wikipedias: English, Spanish, Quechua, Aymara, German, and Portuguese. Coverage is defined as having a Wikipedia article linked from Wikidata via sitelinks.

The maps are designed to support Wikipedia editors who want to identify municipalities lacking articles in one or more languages. They connect to the deeper article-quality analysis in bolivia-municipality-wikipedia.qmd, which examines article content and structure on English Wikipedia.


Setup

Code
library(tidyverse)
library(sf)
library(patchwork)
library(httr)
library(jsonlite)

source("wikidata_presence_matrix.R")
source("R/get_wikidata_instances.R")

Fetch data from Wikidata

Wikipedia presence matrix

We query Wikidata for all items that are instances of municipality of Bolivia (Q1062710) and build a presence matrix indicating which Wikipedia language editions have an article for each municipality.

Results are cached to data/bo_municipality_wiki_presence.rds so that subsequent renders do not repeat the API calls.

Code
presence_cache <- "data/bo_municipality_wiki_presence.rds"

if (file.exists(presence_cache)) {
  bo_municipality_wiki_presence <- readRDS(presence_cache)
} else {
  bo_municipality_wiki_presence <- wikidata_instance_wikipedia_presence(
    class_qid  = "Q1062710",   # municipality of Bolivia
    languages  = NULL,         # auto-discover all languages present
    limit      = 500,
    batch_size = 20
  )
  saveRDS(bo_municipality_wiki_presence, presence_cache)
}

INE codes (P14142)

We retrieve the INE municipal code (property P14142) for each municipality. These 6-digit codes (e.g. 010101) allow us to join Wikidata entities to the GADM boundary file via a pre-built crosswalk.

Code
ine_cache <- "data/municipalities_wd_ine.rds"

if (file.exists(ine_cache)) {
  municipalities_wd_ine <- readRDS(ine_cache)
} else {
  municipalities_wd_ine <- get_wikidata_instances(
    class_qid      = "Q1062710",
    property       = "P14142",
    property_names = "ine_code",
    languages      = c("en", "es"),
    limit          = 500,
    batch_size     = 20
  )
  saveRDS(municipalities_wd_ine, ine_cache)
}

Build map dataset

We join the presence matrix to INE codes, then match to GADM boundaries through the pre-built lookup table.

Code
gadm_sf     <- st_read("data/gadm41_BOL_3.gpkg", layer = "ADM_ADM_3",
                       quiet = TRUE) |>
  select(NAME_1, NAME_3, geom)
gadm_lookup <- readRDS("data/gadm_lookup.rds")

# Join presence matrix → INE codes → GADM crosswalk → spatial boundaries
map_data <- gadm_sf |>
  inner_join(
    gadm_lookup |> select(gadm_dep, gadm_mun, cod.mun),
    by = c("NAME_1" = "gadm_dep", "NAME_3" = "gadm_mun")
  ) |>
  left_join(
    bo_municipality_wiki_presence$data |>
      select(qid, en, es, qu, ay, de, pt) |>
      left_join(
        municipalities_wd_ine |> select(qid, ine_code),
        by = "qid"
      ),
    by = c("cod.mun" = "ine_code")
  ) |>
  mutate(
    across(c(en, es, qu, ay, de, pt),
           ~ factor(case_when(
             .x == 1L ~ "Has article",
             .x == 0L ~ "No article",
             TRUE      ~ "Not in Wikidata"
           ), levels = c("Has article", "No article", "Not in Wikidata")))
  )

Coverage summary

Code
# Count municipalities with / without an article per Wikipedia
coverage_summary <- map_data |>
  st_drop_geometry() |>
  summarise(across(c(en, es, qu, ay, de, pt), list(
    has    = ~ sum(.x == "Has article",      na.rm = TRUE),
    no     = ~ sum(.x == "No article",       na.rm = TRUE),
    absent = ~ sum(.x == "Not in Wikidata" | is.na(.x), na.rm = TRUE)
  ))) |>
  pivot_longer(everything(),
               names_to  = c("language", ".value"),
               names_sep = "_") |>
  mutate(
    wikipedia = c(en = "English", es = "Spanish", qu = "Quechua", ay = "Aymara",
                  de = "German", pt = "Portuguese")[language],
    pct_has   = round(100 * has / (has + no + absent), 1)
  ) |>
  select(wikipedia, has, no, absent, pct_has)

coverage_summary |>
  rename(
    Wikipedia      = wikipedia,
    `Has article`  = has,
    `No article`   = no,
    `Not in WD`    = absent,
    `% covered`    = pct_has
  ) |>
  knitr::kable(caption = "Municipality article coverage by Wikipedia language edition")
Municipality article coverage by Wikipedia language edition
Wikipedia Has article No article Not in WD % covered
English 192 147 0 56.6
Spanish 195 144 0 57.5
Quechua 323 16 0 95.3
Aymara 2 337 0 0.6
German 339 0 0 100.0
Portuguese 9 330 0 2.7

Maps

Colors indicate whether Wikidata links the municipality to a Wikipedia article in each language. Grey polygons are municipalities present in GADM but not matched through Wikidata.

Code
presence_colors <- c(
  "Has article"     = "#2166ac",
  "No article"      = "#f7f7f7",
  "Not in Wikidata" = "#aaaaaa"
)
Code
p_en <- make_presence_map(map_data, "en", "English Wikipedia")
p_es <- make_presence_map(map_data, "es", "Spanish Wikipedia")
p_qu <- make_presence_map(map_data, "qu", "Quechua Wikipedia")
p_ay <- make_presence_map(map_data, "ay", "Aymara Wikipedia")
p_de <- make_presence_map(map_data, "de", "German Wikipedia")
p_pt <- make_presence_map(map_data, "pt", "Portuguese Wikipedia")
p_lg <- make_legend_panel(map_data)

# Flat layout: legend in row 1 col 4, spacer in row 2 col 4
design <- "
ABCD
####
EFG#
"

p_en + p_es + p_qu + p_lg +
  p_ay + p_de + p_pt +
  plot_layout(design = design, heights = c(1, 0.08, 1)) +
  plot_annotation(
    title   = "Bolivia: Municipal Wikipedia Coverage by Language",
    caption = "Source: Wikidata (Q1062710 instances); boundaries: GADM 4.1",
    theme   = theme(
      plot.title = element_text(face = "bold", size = 28, hjust = 0.5)
    )
  )


Municipalities missing across multiple Wikipedias

Municipalities with no article in any of the four languages are the highest-priority targets for new articles. The table below lists them, ordered by INE code.

Code
map_data |>
  st_drop_geometry() |>
  filter(
    en == "No article",
    es == "No article",
    qu == "No article",
    ay == "No article"
#    de == "No article",
#    pt == "No article"
  ) |>
  left_join(
    municipalities_wd_ine |> select(ine_code, label_en, label_es),
    by = c("cod.mun" = "ine_code")
  ) |>
  select(
    `INE code`  = cod.mun,
    `Name (EN)` = label_en,
    `Name (ES)` = label_es,
    English     = en,
    Spanish     = es,
    Quechua     = qu,
    Aymara      = ay,
    German      = de,
    Portuguese  = pt
  ) |>
  arrange(`INE code`) |>
  knitr::kable(caption = "Municipalities with no article in English, Spanish, Quechua, or Aymara")
Municipalities with no article in English, Spanish, Quechua, or Aymara
INE code Name (EN) Name (ES) English Spanish Quechua Aymara German Portuguese
010801 Villa Serrano NA No article No article No article No article Has article No article
031501 Bolívar Municipality Municipio de Bolívar No article No article No article No article Has article No article
041001 Toledo Municipality Toledo No article No article No article No article Has article No article
041101 Eucaliptus Municipality Municipio de Eucaliptus No article No article No article No article Has article No article
041301 San Pedro de Totora Municipality San Pedro de Totora No article No article No article No article Has article No article
051501 Villazón Municipality Municipio Villazón No article No article No article No article Has article No article
051601 San Agustín Municipality Municipio San Agustín No article No article No article No article Has article No article
060101 Tarija Municipality Municipio de Tarija No article No article No article No article Has article No article
070202 Okinawa Uno Municipio de Okinawa Uno No article No article No article No article Has article No article
071201 San Matias Municipality NA No article No article No article No article Has article No article

Next steps

The deeper analysis of existing English Wikipedia articles — article length, citations, infobox completeness, and census data quality — is in bolivia-municipality-wikipedia.qmd, with results saved to data/bolivia_municipality_wikipedia.rds.

Future work here will:

  • Add a table of municipalities missing only in one language, to guide targeted translation campaigns
  • Link article quality metrics (from bolivia_municipality_wikipedia.rds) to the coverage maps
  • Track changes over time as new articles are created