kaz_adm2_sf | R Documentation |
A MULTIPOLYGON sf
object including all districts (rayons) of Kazakhstan (2024 version).
They contain 226 Rayons of Oblast & City of Oblast Significance and also Rayons of City of
Republican Significance. The borders of districts were corrected by Alexander Rodionov in
QGIS.
data(kaz_adm2_sf)
A MULTIPOLYGON
data frame (resolution: 1:1million, EPSG:4326 or WGS84 - World Geodetic System 1984) object with
224 rows and fields:
KATO: Classifier of Administrative Territorial Objects (rus. KATO)
ADM0_EN: Name of country on Latin characters
ADM0_KK: Name of country on Kazakh (Cyrillic) characters
ADM0_RU: Name of country on Russian (Cyrillic) characters
ADM0_PCODE: Two first characters of code according ISO 3166-2 ("KZ")
ADM1_EN: Name of Administrative units level 1 on Latin characters
ADM1_KK: Name of Administrative units level 1 on Kazakh (Cyrillic) characters
ADM1_RU: Name of Administrative units level 1 on Russian (Cyrillic) characters
ADM1_PCODE: Two first characters of code according ISO 3166-2 ("KZ") + AB characters of KATO (two first characters from TE)
ADM2_EN: Name of Administrative units level 2 on Latin characters
ADM2_KK: Name of Administrative units level 2 on Kazakh (Cyrillic) characters
ADM2_RU: Name of Administrative units level 2 on Russian (Cyrillic) characters
ADM2_PCODE: Two first characters of code according ISO 3166-2 ("KZ") + (AB characters of KATO + CD characters of KATO + EF characters of KATO) or six first characters from TE
ISO_3166_2: Codes for the principal subdivisions coded in ISO 3166-2.
Year: Versions of Administrative-territorial divisions of the country in 2024 year
geometry: geometry field (sf
object).
% man/figures/Kazakhstan2024.png
https://data.humdata.org/dataset/cod-ab-kaz, files of 2024 year
kaz_admbnda_adm2_2024.shp
, kaz_admbnda_adm2_2024.shx
, kaz_admbnda_adm2_2024.dbf
,
kaz_admbnda_adm2_2024.prj
& kaz_admbnda_adm2_2024.cpg
;
get_kaz_rayons_map
package vignette or vignette("making_maps", package = "geokz")
Other datasets with geographic features:
kaz_adm0_sf
,
kaz_adm1_2018_sf
,
kaz_adm1_sf
,
kaz_adm2_2018_sf
,
kaz_cnt1_sf
data("kaz_adm1_sf")
data("kaz_adm2_sf")
library(sf)
# EPSG:4326 or WGS84 - see https://github.com/r-spatial/sf/issues/1419
sf::st_crs(x = kaz_adm2_sf) <- 4326L
# A Lambert Conformal Conic projection (LCC) with Krasovsky 1940 ellipsoid
# <https://proj.org/operations/projections/lcc.html>
# First standard parallel - 45 N, Second standard parallel - 51 N,
# Longitude of projection center - 67 E, Latitude of projection center - 48 N.
# See https://epsg.io/2502
kaz_adm2_sf <-
sf::st_transform(x = kaz_adm2_sf,
crs = "+proj=lcc +lon_0=67 +lat_1=45 +lat_2=51 +ellps=krass")
plot(x = kaz_adm2_sf["ADM2_EN"], border = "grey",
main = "Kazakhstan: Rayons & Cities of Oblast Significance (ADM2)")
# Administrative Map of Units Level 1 & Level 2
# EPSG:4326 or WGS84 - see https://github.com/r-spatial/sf/issues/1419
sf::st_crs(x = kaz_adm1_sf) <- 4326L
kaz_adm1_sf <-
sf::st_transform(x = kaz_adm1_sf,
crs = "+proj=lcc +lon_0=67 +lat_1=45 +lat_2=51 +ellps=krass")
plot(x = kaz_adm2_sf["ADM2_EN"], reset = FALSE,
col = rev(sf::sf.colors(nrow(kaz_adm2_sf))), border = "grey",
main = "Kazakhstani Oblasts: Rayons & Cities of Oblast Significance (ADM2)")
# when plotting some coverages, the reset = FALSE is needed:
plot(x = sf::st_geometry(kaz_adm1_sf), lwd = 2, border = "darkred", add = TRUE)
# Use {tmap} package for draw of Thematic Maps
if (requireNamespace("tmap", quietly = TRUE)) {
library(tmap)
tmap::qtm(shp = kaz_adm2_sf, fill = "ADM1_PCODE",
border = 'grey', scale = 0.8, frame = TRUE,
title = "Kazakhstan: Adm. units level 2 (Rayons & Cities of Oblast Significance)\n",
fill.title = "Oblasts & \nCities of Republican \nSignificance",
fill.labels = kaz_adm1_sf$ADM1_KK,
format = 'World_wide'
) +
tmap::tm_graticules(lines = FALSE)
# Facets with {tmap}: by splitting the spatial data with the by argument of tmap::tm_facets
tmap::tm_shape(
kaz_adm2_sf,
# Web Mercator / Pseudo Mercator. See <https://proj.org/operations/projections/webmerc.html>.
projection = "+proj=webmerc +datum=WGS84"
) +
tmap::tm_polygons(
col = "ADM1_PCODE",
palette = "RdYlBu",
border.col = 'grey',
legend.show = FALSE
) +
tmap::tm_facets(by = "ADM1_EN") +
tmap::tm_layout(
main.title = "Kazakhstan: Administrative units level 1
(Oblasts & Cities of Republican Significance)",
legend.position = NULL
)
} # The end for {tmap} package
# Use {ggplot2} package for draw of Advanced Maps as `sf` objects
if (requireNamespace(c("ggplot2", "RColorBrewer", "dplyr"), quietly = TRUE)) {
library(ggplot2)
library(RColorBrewer)
library(dplyr)
kaz_adm2_sf |>
dplyr::filter(ADM1_EN =="Mangystau") |>
dplyr::mutate(ADM2_EN = factor(ADM2_EN, levels = ADM2_EN)) |>
ggplot2::ggplot() +
ggplot2::geom_sf(mapping = ggplot2::aes(fill = ADM2_EN)) + # forcats::fct_inorder(ADM2_EN)
ggplot2::geom_sf_text(
mapping = ggplot2::aes(label = ADM2_EN),
size = 3
) +
ggplot2::coord_sf(crs=2499) + # Pulkovo 1942 / Gauss-Kruger CM 51E. See <https://epsg.io/2499>.
ggplot2::scale_fill_brewer(palette = "Pastel2") + # uses library(RColorBrewer)
ggplot2::theme_light() +
ggplot2::guides(fill = ggplot2::guide_legend(title = "Administrative \nunits level 2")) +
ggplot2::labs(title = "Kazakhstan: Mangystau Oblast
(Rayons & Cities of Oblast Significance)",
x = NULL,
y = NULL,
caption = "Source: package {geokz}"
)
} # The end for {ggplot2} package
# Use {leaflet} package for draw of Interactive Maps as `sf` objects
if (requireNamespace("leaflet", "magrittr", quietly = TRUE)) {
library(leaflet)
library(magrittr)
pal <- leaflet::colorNumeric("Pastel2", domain =as.integer(kaz_adm1_sf$KATO))
leaflet::leaflet(data = sf::st_zm(geokz::kaz_adm1_sf, geometry)) |>
leaflet::addProviderTiles(provider = "Esri.WorldShadedRelief") |>
leaflet::addPolygons(
weight = 2,
color = "darkred",
opacity = 1,
fillColor = ~pal(as.integer(KATO)),
fillOpacity = 0.3,
smoothFactor = 0.5,
) |>
leaflet::addPolygons(
data = geokz::kaz_adm2_sf,
weight = 1,
color = "grey",
fillColor = NULL,
smoothFactor = 0.5,
label = ~paste(ADM1_EN, "Region :", ADM2_EN),
labelOptions = labelOptions(direction = "auto"),
highlightOptions = highlightOptions(color = "red", weight = 3, bringToFront = TRUE)
)
} # The end for {leaflet} package
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.