mn_bags: Bags: the smallest rural units

View source: R/bags.R

mn_bagsR Documentation

Bags: the smallest rural units

Description

Bags (baga) are the subdivisions of soums; there are about 1,650 of them. Their codes and names are built in (see mn_codes("bag")), but their boundaries are not openly published: the National Statistics Office of Mongolia (NSO) shares them on request. Once you have a bag boundary file, mn_bags() and every other function in the package can use it.

Usage

mn_bags(
  aimag = NULL,
  soum = NULL,
  path = getOption("mongolmaps.bags_path"),
  resolution = c("low", "high"),
  lang = NULL,
  crs = NULL
)

mn_read_bags(path, code_col = NULL, check_nesting = TRUE)

Arguments

aimag, soum

Keep only bags in these aimags or soums (names or codes).

path

Path to a bag boundary file readable by sf::st_read(). Defaults to getOption("mongolmaps.bags_path").

resolution

"low" (default) uses simplified boundaries that ship with the package and suit most maps. "high" uses full-resolution boundaries, downloaded once (about 10 MB) and cached; see mn_cache_dir().

lang

Language of the name column: "en" (English, as in NSO tables), "mn" (Cyrillic) or "mns" (Latin with diacritics, MNS 5217). Defaults to getOption("mongolmaps.lang", "en").

crs

Coordinate reference system of the result. NULL (default) keeps longitude/latitude (EPSG:4326). Use "albers", "lcc" or "utm" for a projection suited to Mongolia (see mn_crs()), or any value accepted by sf::st_crs().

code_col

Name of the column holding bag codes: 7-digit NSO codes ("1830151") or P-codes ("MN830151"). NULL detects it.

check_nesting

If TRUE (default), stop when a bag lies outside its soum.

Value

An sf tibble; see mn_admin() for the columns.

Getting bag boundaries

Write to NSO (international@nso.mn) and ask for the bag boundaries as a shapefile or GeoPackage, with each bag's NSO code. Then either pass the file to mn_bags(path = ...), or register it once per session with options(mongolmaps.bags_path = "path/to/bags.gpkg") (put that line in your .Rprofile to make it permanent). Registered bags are also returned by mn_admin("bag") and used by mn_join().

mn_read_bags() checks the file: every bag must have a known code and sit inside its soum.

See Also

Other admin boundaries: mn_admin(), mn_aimags(), mn_country(), mn_soums(), mn_ub()

Examples

# Codes and names of all bags, without boundaries:
mn_codes("bag", within = "Khovd")

# Without a bag boundary file, mn_bags() explains how to get one:
try(mn_bags())

# With the file from NSO (not run, as the file is not public):
## Not run: 
mn_bags(aimag = "Khovd", path = "bags_from_nso.gpkg")

## End(Not run)

mongolmaps documentation built on Oct. 10, 2026, 5:08 p.m.