Skip to contents
library(mongolstats)
library(mongolmaps)
library(dplyr)
library(ggplot2)
library(sf)
library(tidyr)

# Checked teaching helpers are shipped with the package and can be inspected.
source(system.file("examples", "analysis-helpers.R", package = "mongolstats"), local = TRUE)
source(system.file("examples", "plot-style.R", package = "mongolstats"), local = TRUE)

Introduction

Ulaanbaatar, the capital of Mongolia, is home to about half of the country’s population. This vignette looks at its nine districts (duureg) using NSO tables published “by soum and district”: population and growth, school capacity, the air quality monitoring network, and the limits of district-level health statistics.

Districts and Their Codes

mongolmaps provides the district boundaries with their NSO codes and areas, so NSO tables join without matching names.

ub_districts <- mn_ub_districts()
ub_districts |>
  st_drop_geometry() |>
  select(name, nso_code, area_km2)
#> # A tibble: 9 × 3
#>   name             nso_code area_km2
#>   <chr>            <chr>       <dbl>
#> 1 Baganuur         51101       625. 
#> 2 Bagakhangai      51104       156. 
#> 3 Bayangol         51107        24.8
#> 4 Bayanzurkh       51110      1237. 
#> 5 Nalaikh          51113       689. 
#> 6 Songinokhairkhan 51116      1204. 
#> 7 Sukhbaatar       51119       211. 
#> 8 Khan-Uul         51122       498. 
#> 9 Chingeltei       51125        91.1

# Fetch an NSO table for the nine districts only
get_ub_data <- function(tbl_id, selections = list()) {
  data <- nso_data(
    tbl_id,
    selections = c(list(Region = ub_districts$nso_code), selections),
    labels = "en"
  ) |>
    mutate(District = trimws(Region_en))
  expected <- tidyr::expand_grid(
    Region = ub_districts$nso_code,
    Year_en = as.character(selections$Year)
  )
  analysis_keys(data, c("Region", "Year_en"), expected)
  data
}

# Latest year a table covers
latest_year <- function(tbl_id) {
  analysis_latest_common_year(tbl_id)
}

1. Demographic Profile

Population Density

The population table DT_NSO_0300_002V4 gives the mid-year resident population down to khoroo level. (This table id names two tables in the catalogue; mongolstats warns and uses the first match, which is the khoroo-level table and also includes the districts.)

pop_tbl <- "DT_NSO_0300_002V4"
pop_year <- latest_year(pop_tbl)

pop_data <- get_ub_data(pop_tbl, list(Year = pop_year))

ub_pop_map <- pop_data |>
  mn_join(by = "Region", level = "soum", within = "Ulaanbaatar") |>
  mutate(density = if_else(is.finite(value) & value > 0 &
      is.finite(area_km2) & area_km2 > 0,
    value / area_km2, NA_real_
  ))
stopifnot(nrow(ub_pop_map) == 9L, !anyDuplicated(ub_pop_map$nso_code))

mn_map(
  ub_pop_map,
  fill = density, trans = "log10", label = TRUE,
  title = paste0("Population Density by District, ", pop_year)
) +
  labs(
    subtitle = "Residents per km² (log scale)",
    fill = "Residents\nper km²",
    caption = "Source: NSO Mongolia, DT_NSO_0300_002V4"
  ) +
  guides(fill = guide_colourbar(barwidth = grid::unit(85, "mm"), barheight = grid::unit(3, "mm"))) +
  analysis_map_theme()

Map of population density by Ulaanbaatar district on a log scale, with each district labelled

Bayangol is the densest district, with about 10,400 residents per km². Bagakhangai is the least dense, at about 28 per km². Districts such as Bayanzurkh and Songinokhairkhan include large areas of mountain and pasture, so a district average hides very dense neighbourhoods. Khoroo-level data show more detail:

khoroo_codes <- nso_dim_values(pop_tbl, "Region")$code |>
  stringr::str_subset("^511\\d{4}$") # seven-digit codes are khoroos

khoroo_raw <- nso_data(
  pop_tbl, list(Region = khoroo_codes, Year = pop_year),
  labels = "en"
)
analysis_keys(khoroo_raw, "Region", tibble(Region = khoroo_codes))
khoroo_status <- nso_value_status(khoroo_raw)
khoroo_check <- khoroo_raw |>
  mutate(Region = substr(Region, 1, 5)) |>
  summarise(khoroo_sum = analysis_sum(value), .by = Region) |>
  full_join(select(pop_data, Region, district_total = value),
    by = join_by(Region), relationship = "one-to-one"
  ) |>
  mutate(agrees = is.finite(khoroo_sum) & is.finite(district_total) & khoroo_sum == district_total)
khoroo_check |>
  mutate(agrees = if_else(agrees, "Yes", "No")) |>
  knitr::kable(
    col.names = c("District code", "Khoroo total", "District total", "Totals agree"),
    digits = 0, format.args = list(big.mark = ","),
    caption = "Population reconciliation before using the illustrative khoroo map"
  )
Population reconciliation before using the illustrative khoroo map
District code Khoroo total District total Totals agree
51101 29,076 29,076 Yes
51104 4,401 4,401 Yes
51107 257,391 257,391 Yes
51110 452,084 452,084 Yes
51113 40,781 40,781 Yes
51116 341,746 341,746 Yes
51119 142,356 142,356 Yes
51122 278,532 278,532 Yes
51125 131,278 131,278 Yes
khoroo_pop <- mn_join(khoroo_raw, by = "Region", level = "bag", within = "Ulaanbaatar") |>
  mutate(density = if_else(is.finite(value) & value > 0 &
      is.finite(area_km2) & area_km2 > 0,
    value / area_km2, NA_real_
  ))
stopifnot(!anyDuplicated(khoroo_pop$nso_code))
unmapped_khoroos <- setdiff(khoroo_raw$Region, khoroo_pop$nso_code)

central <- c("Bayangol", "Bayanzurkh", "Chingeltei", "Khan-Uul", "Songinokhairkhan", "Sukhbaatar")
mn_map(
  filter(khoroo_pop, parent_pcode %in% ub_districts$pcode[ub_districts$name %in% central]),
  fill = density, trans = "log10",
  title = paste0("Population Density by Khoroo, Central Ulaanbaatar, ", pop_year)
) +
  labs(subtitle = "Residents per km² (log scale), six central districts", fill = "Residents\nper km²") +
  guides(fill = guide_colourbar(barwidth = grid::unit(85, "mm"), barheight = grid::unit(3, "mm"))) +
  analysis_map_theme()

Map of population density by khoroo in Ulaanbaatar's six central districts on a log scale

The khoroo boundaries are unofficial. 0 source codes lack a matched boundary. The reconciliation table does not establish a matching boundary vintage: splits, mergers and changed codes still need review. This is an illustrative density map, not validated fine-scale risk or exposure data. Missing or nonpositive values are not plotted on the log scale.

Rapid growth can strain local health and school services.

trend_years <- as.character(as.integer(pop_year) - 9:0)
pop_trend <- get_ub_data(pop_tbl, list(Year = trend_years)) |>
  mutate(Year = as.integer(Year_en))

pop_trend |>
  ggplot(aes(x = Year, y = value)) +
  geom_line(linewidth = 1, color = "#167D8D") +
  geom_point(size = 1.5, color = "#167D8D") +
  facet_wrap(~District, ncol = 3) +
  scale_y_continuous(labels = scales::label_comma()) +
  scale_x_continuous(breaks = as.integer(trend_years)[c(1, 5, 10)]) +
  labs(
    title = paste0("Resident Population by District, ", min(trend_years), "–", max(trend_years)),
    subtitle = "Mid-year resident population",
    y = "Population", x = NULL,
    caption = "Source: NSO Mongolia, DT_NSO_0300_002V4"
  ) +
  theme(legend.position = "bottom", panel.grid.minor = element_blank())

Nine small-multiple line charts of resident population by Ulaanbaatar district over the last 10 years, on a shared population scale

Across the ten annual observations from 2016 to 2025, there are nine elapsed years. The table below shows signed total and annualised changes; negative values are declines. Baganuur had the smallest absolute percentage change. Changes in these totals do not identify migration or service capacity by themselves.

knitr::kable(growth,
  col.names = c("District", "Elapsed years", "Total change (%)", "Annualised change (%)"),
  digits = c(0, 0, 1, 1), caption = "Population change over the observed interval"
)
Population change over the observed interval
District Elapsed years Total change (%) Annualised change (%)
Khan-Uul 9 79.5 6.7
Bayanzurkh 9 39.5 3.8
Bayangol 9 22.6 2.3
Nalaikh 9 12.9 1.4
Songinokhairkhan 9 9.7 1.0
Bagakhangai 9 6.4 0.7
Sukhbaatar 9 3.8 0.4
Baganuur 9 1.3 0.1
Chingeltei 9 -16.1 -1.9

2. School Enrolment

NSO publishes few socioeconomic indicators by district. The number of students per general education school gives a rough measure of pressure on public services.

edu_year <- analysis_latest_common_year(c("DT_NSO_2001_002V2", "DT_NSO_2002_057V2"))
schools <- get_ub_data("DT_NSO_2001_002V2", list(Year = edu_year)) |>
  select(Region, District, Schools = value)
students <- get_ub_data("DT_NSO_2002_057V2", list(Year = edu_year)) |>
  select(Region, Students = value)

edu_load <- analysis_pair(schools, students, "Region")
analysis_count_values(edu_load$Schools)
analysis_count_values(edu_load$Students)
stopifnot(
  all(is.finite(edu_load$Schools)), all(edu_load$Schools > 0),
  all(is.finite(edu_load$Students))
)
edu_load <- mutate(edu_load, Students_Per_School = Students / Schools)

ggplot(edu_load, aes(x = Students_Per_School, y = reorder(District, Students_Per_School))) +
  geom_col(fill = "#167D8D", width = 0.7) +
  geom_text(aes(label = round(Students_Per_School)), hjust = -0.1, size = 3) +
  scale_x_continuous(labels = scales::label_comma(), expand = expansion(mult = c(0, 0.15))) +
  labs(
    title = paste0("Students per General Education School, ", edu_year),
    subtitle = "Full-time students divided by number of schools",
    x = "Students per school", y = NULL,
    caption = "Source: NSO Mongolia, DT_NSO_2001_002V2 and DT_NSO_2002_057V2"
  ) +
  theme(panel.grid.major.y = element_blank(), panel.grid.minor = element_blank())

Bar chart of students per general education school by Ulaanbaatar district

This ratio is mean enrolment per institution, not classroom size, spare capacity, crowding or deprivation. Schools differ in size, sector and shift system. Confirm that the school-year definition and institutional coverage match between the two sources.

3. Health Statistics by District: A Caution

Rates need a numerator and denominator for the same population. Very uneven recorded births or deaths per resident can reveal incompatible geographic assignment or coverage. The diagnostic below is not a comparison of resident health risks; source-specific residence versus occurrence definitions still need confirmation.

vital_year <- analysis_latest_common_year(c("DT_NSO_2100_027V1", "DT_NSO_2100_018V6", pop_tbl))

births <- get_ub_data(
  "DT_NSO_2100_018V6",
  list(Indicator = "0", Year = vital_year) # Indicator "0" = both sexes
) |>
  select(Region, District, count = value) |>
  mutate(measure = "Live births per 1,000 residents")

deaths <- get_ub_data(
  "DT_NSO_2100_027V1",
  list(Indicator = "0", Year = vital_year) # Indicator "0" = all deaths
) |>
  select(Region, District, count = value) |>
  mutate(measure = "Deaths per 1,000 residents")

residents <- get_ub_data(pop_tbl, list(Year = vital_year)) |>
  select(Region, residents = value)

vital_rates <- bind_rows(births, deaths) |>
  left_join(residents, by = join_by(Region), relationship = "many-to-one") |>
  mutate(rate = count / residents * 1000)

stopifnot(
  all(is.finite(vital_rates$count)), all(is.finite(vital_rates$residents)),
  all(vital_rates$residents > 0)
)

vital_rates |>
  ggplot(aes(x = rate, y = reorder(District, residents))) +
  geom_col(fill = "#5B6E9A", width = 0.7) +
  geom_text(aes(label = round(rate, 1)), hjust = -0.1, size = 3) +
  facet_wrap(~measure, scales = "free_x") +
  scale_x_continuous(expand = expansion(mult = c(0, 0.2))) +
  labs(
    title = paste0("Recorded Births and Deaths per 1,000 Residents, ", vital_year),
    subtitle = "Districts ordered by number of residents",
    x = NULL, y = NULL,
    caption = "Source: NSO Mongolia, DT_NSO_2100_018V6, DT_NSO_2100_027V1 and DT_NSO_0300_002V4"
  ) +
  theme(panel.grid.major.y = element_blank(), panel.grid.minor = element_blank())

Two-panel bar chart of live births and deaths per 1,000 residents by Ulaanbaatar district, showing implausible differences between districts

The observed differences are consistent with occurrence-based reporting or another mismatch in coverage. They do not establish the precise assignment rule. Do not interpret the diagnostic ratios as resident birth or death rates until NSO or the Health Development Center confirms the definitions for each table.

Do not correlate these diagnostic ratios with density or environmental measures as though they describe residents. Obtain compatible residence-coded events and populations for district comparisons. City-wide aggregation may reduce internal district mismatch, but does not by itself resolve referrals into the capital or inconsistent source coverage.

4. Air Quality Monitoring Network

The following is an illustrative inventory of 18 approximate station locations, not a verified list of active monitoring sites. The original compilation referred to public listings, including the World Air Quality Index project, but did not retain a per-coordinate URL or verification date. Those fields remain unknown; verify official coordinates, operating periods and pollutant coverage before exposure assignment or network planning.

ub_aq_stations <- tribble(
  ~Station, ~Latitude, ~Longitude,
  "Misheel-Expo center", 47.89428, 106.8825,
  "West crossroad", 47.91576, 106.8940,
  "1st micro district", 47.91798, 106.8481,
  "13th micro district", 47.91761, 106.9374,
  "32nd Toirog", 47.939333, 106.914333,
  "Ofitseruudiin ordon", 47.916611, 106.972556,
  "Kharkhorin market", 47.910583, 106.837111,
  "Urgakh naran micro district", 47.873778, 107.115028,
  "Dambdarjaa", 47.988250, 106.951167,
  "Khailaast", 47.963528, 106.893889,
  "Tolgoit", 47.920278, 106.799250,
  "Zuragt", 47.92973, 106.8886,
  "Amgalan", 47.906250, 107.016556,
  "Nisekh", 47.86394, 106.7791,
  "Tavan buudal", 47.954500, 106.914833,
  "Bayankhoshuu", 47.945528, 106.822917,
  "Sharkhad", 47.93375, 107.0103,
  "100 ail", 47.93291, 106.9214
)

# Keep missing provenance explicit rather than inventing sources or dates.
ub_aq_stations <- ub_aq_stations |>
  mutate(
    coordinate_source = "Historical illustrative compilation; unverified",
    verified_at = NA_character_, operating_period = NA_character_,
    pollutant_coverage = NA_character_
  )

# Only unique polygon assignments count toward a district's inventory.
station_points <- st_as_sf(ub_aq_stations, coords = c("Longitude", "Latitude"), crs = 4326)
polygon_matches <- st_intersects(station_points, ub_districts)
station_points$assignment <- if_else(lengths(polygon_matches) == 1L, "Unique", "Unresolved")
# Assign each uniquely located station to a district
ub_stations_sf <- station_points |>
  filter(assignment == "Unique") |>
  st_join(select(ub_districts, District = name))
analysis_keys(st_drop_geometry(ub_stations_sf), "Station")
unresolved_stations <- station_points |>
  filter(assignment != "Unique") |>
  st_drop_geometry() |>
  select(Station, assignment)

# Station count for every district, including those with none
station_count <- ub_districts |>
  st_drop_geometry() |>
  select(District = name) |>
  left_join(count(st_drop_geometry(ub_stations_sf), District, name = "Stations"), by = join_by(District)) |>
  mutate(Stations = coalesce(Stations, 0L)) |>
  arrange(desc(Stations))

All listed station locations have a unique district assignment.

Uniquely assigned locations in the illustrative inventory by district
District Listed locations
Bayanzurkh 5
Bayangol 3
Songinokhairkhan 3
Sukhbaatar 3
Khan-Uul 2
Chingeltei 2
Baganuur 0
Bagakhangai 0
Nalaikh 0

Stations are assigned by their coordinates, using mongolmaps’ simplified district boundaries. A station within a few hundred metres of a district border may fall on the other side.

Spatial Distribution

# Zoom to the stations, with a 3 km margin, in UTM zone 48N (metres)
utm48n <- 32648
station_box <- ub_stations_sf |>
  st_transform(utm48n) |>
  st_buffer(3000) |>
  st_bbox()

mn_map(filter(ub_districts, name %in% central),
  label = FALSE, crs = utm48n,
  title = "Air Quality Monitoring Stations in Central Ulaanbaatar"
) +
  geom_sf(data = ub_stations_sf, color = "#C2623D", size = 2.5, alpha = 0.9) +
  ggrepel::geom_text_repel(
    data = ub_stations_sf, aes(label = Station, geometry = geometry), stat = "sf_coordinates",
    size = 2.4, color = "grey20", min.segment.length = 0, seed = 1
  ) +
  coord_sf(
    crs = utm48n, datum = NA,
    xlim = station_box[c("xmin", "xmax")], ylim = station_box[c("ymin", "ymax")]
  ) +
  labs(subtitle = "Red points = monitoring stations (approximate locations)") +
  analysis_map_theme()

Map of Ulaanbaatar's central districts with air quality monitoring stations shown as red points

Coverage

station_coverage <- station_count |>
  left_join(select(pop_data, District, Population = value), by = join_by(District)) |>
  mutate(Pop_per_Station = if_else(Stations > 0, Population / Stations, NA_real_))

station_coverage |>
  mutate(Pop_per_Station = if_else(Stations > 0,
    scales::comma(Pop_per_Station, accuracy = 1), "Not applicable"
  )) |>
  knitr::kable(
    col.names = c("District", "Listed locations", "Population", "Residents per listed location"),
    digits = 0, format.args = list(big.mark = ","),
    caption = "All districts, including those without a listed location"
  )
All districts, including those without a listed location
District Listed locations Population Residents per listed location
Bayanzurkh 5 452,084 90,417
Bayangol 3 257,391 85,797
Songinokhairkhan 3 341,746 113,915
Sukhbaatar 3 142,356 47,452
Khan-Uul 2 278,532 139,266
Chingeltei 2 131,278 65,639
Baganuur 0 29,076 Not applicable
Bagakhangai 0 4,401 Not applicable
Nalaikh 0 40,781 Not applicable

station_coverage |>
  filter(Stations > 0) |>
  ggplot(aes(x = Pop_per_Station / 1000, y = reorder(District, Pop_per_Station))) +
  geom_col(fill = "#167D8D", width = 0.7) +
  geom_text(aes(label = paste0(round(Pop_per_Station / 1000), "k (", Stations, ")")), hjust = -0.1, size = 3) +
  scale_x_continuous(expand = expansion(mult = c(0, 0.25))) +
  labs(
    title = "Residents per Listed Station Location",
    subtitle = "Thousands of residents per station (number of stations in brackets)",
    x = "Residents per station (thousands)", y = NULL,
    caption = paste("Population year", pop_year, "| Districts with no listed location remain in the table")
  ) +
  theme(panel.grid.major.y = element_blank(), panel.grid.minor = element_blank())

Bar chart of residents per monitoring station for each Ulaanbaatar district that has at least one station

3 districts have no uniquely assigned location in this inventory. This does not establish absence of monitoring. Residents per listed location does not measure representativeness; operating status, pollutant coverage, terrain and distance from sources matter. These ratios cannot determine where another monitor would add the most information.

Conclusion

The tables show differences in recorded population and mean school enrolment. Fine-scale density remains illustrative until boundary vintages are checked. Health comparisons require compatible residence-coded events, and the station inventory needs official verification before assessing exposure or monitoring adequacy.