knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4.2, # Sharp figures on the website; small ones in the CRAN package. dpi = if (identical(Sys.getenv("IN_PKGDOWN"), "true")) 200 else 96, eval = rlang::is_installed("ggplot2") )
mongolmaps gives you ready-made maps of Mongolia. Everything in this vignette works offline: simplified boundaries ship with the package.
library(mongolmaps)
Mongolia has 21 aimags (provinces) and the capital, Ulaanbaatar. Aimags are divided into soums, and soums into bags. Ulaanbaatar is divided into 9 districts (duureg) and those into khoroos.
| Level in mongolmaps | Rural units | Ulaanbaatar units |
|---|---|---|
| "country" | Mongolia | |
| "region" | 4 economic regions | Ulaanbaatar is the 5th |
| "aimag" | 21 aimags | Ulaanbaatar |
| "soum" | 330 soums | 9 districts |
| "bag" | ~1,650 bags | 204 khoroos |
Each level has a function:
mn_aimags()
All of them return the same columns:
pcode: a code that identifies the unit at any level;name, name_en, name_mn, name_mns: the name in the chosen
language, in English (as NSO writes it), in Cyrillic, and in Latin with
diacritics;level, type, number: what kind of unit it is;iso_code, nso_code: ISO 3166-2 and NSO statistical codes;parent_pcode, region_pcode, aimag_pcode, soum_pcode: the units it
sits in;area_km2 and the geometry.Pass the places you want. Names can be spelled any common way.
mn_soums(aimag = "Khovd") mn_aimags(region = "Western")
mn_map() draws any of these with ggplot2.
mn_map(mn_soums(aimag = c("Khovd", "Uvs", "Bayan-Ulgii")), fill = aimag_pcode, label = TRUE)
It returns a normal ggplot, so you can keep adding to it:
library(ggplot2) mn_map(mn_aimags()) + geom_sf(data = mn_settlements(type = c("capital", "aimag_centre")), colour = "firebrick") + labs(title = "Aimag centres")
With context = TRUE you get neighbouring countries, rivers and lakes:
mn_map(mn_regions(), fill = name, context = TRUE)
Boundaries come in longitude and latitude (EPSG:4326). mn_map() projects
them for you; to project them yourself use crs:
mn_aimags(crs = "albers")
mn_crs() returns the projections: Albers equal-area for national maps,
UTM zone 48N for Ulaanbaatar.
mn_map(mn_aimags(lang = "mn"), label = TRUE, lang = "mn")
Set options(mongolmaps.lang = "mn") to use Mongolian everywhere.
The bundled boundaries are simplified. For detailed work, use
resolution = "high": the full-resolution boundaries (about 10 MB) are
downloaded once and cached.
mn_soums(aimag = "Khovd", resolution = "high")
mn_sources()[c("id", "provider", "license")]
Please credit the providers; mn_citation() gives the text.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.