kaz_adm1_sf: Map of All Administrative units level 1 (the principal units...

kaz_adm1_sfR Documentation

Map of All Administrative units level 1 (the principal units of a country) of Kazakhstan in 2024 Year

Description

A sf object including All Administrative units level 1 (the largest subnational units of a country) MULTIPOLYGON objects of Kazakhstan in 2024 year. It contains in 5 January 2024 17 regions, the Capital - Nur-Sultan (city) and 3 Cities of Republican Significance.

Usage

data(kaz_adm1_sf)

Format

A MULTIPOLYGON data frame (resolution: 1:1million, EPSG:4326 or WGS84 - World Geodetic System 1984) object with 20 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)

  • ISO_3166_2: Codes for the principal subdivisions coded in ISO 3166-2

  • Year: Version of Administrative-territorial divisions of the country in 2024 year

  • geometry: geometry field (sf object).

Source

https://data.humdata.org/dataset/cod-ab-kaz, files of 2024 year kaz_admbnda_adm1_2024.shp, kaz_admbnda_adm1_2024.shx, kaz_admbnda_adm1_2024.dbf, kaz_admbnda_adm1_2024.prj & kaz_admbnda_adm1_2024.cpg.

See Also

get_kaz_oblasts_map

package vignette or vignette("making_maps", package = "geokz")

Other datasets with geographic features: kaz_adm0_sf, kaz_adm1_2018_sf, kaz_adm2_2018_sf, kaz_adm2_sf, kaz_cnt1_sf

Examples

data("kaz_adm1_sf")

library(sf)

# EPSG:4326 or WGS84 - see https://github.com/r-spatial/sf/issues/1419
sf::st_crs(x = kaz_adm1_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/????

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_adm1_sf["ADM1_EN"],
     main = "Kazakhstan: Oblasts & Cities of Republican Significance (ADM1)")


# Use {tmap} package for draw of Thematic Maps

if (requireNamespace("tmap", quietly = TRUE)) {

library(tmap)

tmap::tm_shape(kaz_adm1_sf) +
tmap::tm_polygons(
  col = "ADM1_PCODE",
  border.col = "black",
  border.alpha = 0.3,
  title = "Administrative \nunits level 1",
  labels = kaz_adm1_sf$ADM1_EN,
  palette = c("coral", "orange", "green", "blue")
) +
tmap::tm_text("ADM1_EN", col = "gray10", size = 0.9, shadow = TRUE) +
tmap::tm_graticules(lines = FALSE) +
tmap::tm_format(format = 'World_wide') +
tmap::tm_layout(
  main.title = "Kazakhstan: Administrative units level 1
(Oblasts & Cities of Republican Significance)",
  main.title.size = 0.9,
  legend.position = c("left", "bottom")
) +
tmap::tm_credits('Source: package {geokz}', position = c('right', 'BOTTOM'), size = 1.2)

}  # The end for {tmap} package


# Use {ggplot2} package for draw of Advanced Maps as `sf` objects

if (requireNamespace(c("ggplot2", "dplyr"), quietly = TRUE)) {

library(ggplot2)
library(dplyr)

kaz_adm1_sf |>
  dplyr::mutate(ADM1_EN = factor(ADM1_EN, levels = ADM1_EN)) |>
  ggplot2::ggplot() +
    ggplot2::geom_sf(mapping = ggplot2::aes(fill = ADM1_EN)) +
    ggplot2::geom_sf_text(mapping = ggplot2::aes(label = ADM1_EN)) +
    ggplot2::theme_bw() +
    ggplot2::guides(fill = ggplot2::guide_legend(
                                    title = "Administrative \nunits level 1")) +
    ggplot2::labs(title = "Kazakhstan: Administrative units level 1
(Oblasts & Cities of Republican Significance)",
      x = NULL,
      y = NULL,
      caption = "Source: package {geokz}"
    )

}  # The end for {ggplot2} package


#' @section leaflet:
#' Use {leaflet} package for draw of Interactive Maps as `sf` objects

# Use {leaflet} package for draw of Interactive Maps as `sf` objects

if (requireNamespace("leaflet", "magrittr", quietly = TRUE)) {

library(leaflet)
library(magrittr)

# 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/????

points <-
  data.frame(
    name = c("Astana", "Almaty"),
    branch = c("The Capital", "The Biggest City"),
    link = c("https://en.wikipedia.org/wiki/Nur-Sultan",
             "https://en.wikipedia.org/wiki/Almaty"),
    lat = c(51.166667, 43.2775),
    lon = c(71.433333, 76.8958)
  ) |>
  sf::st_as_sf(
    coords = c("lon", "lat"), # columns with geometry by x - "lon" and y - "lat"
    crs = "+proj=longlat +datum=WGS84"
  )

pal <- leaflet::colorNumeric("Blues", domain =as.integer(kaz_adm1_sf$KATO))
epsg102027 <- leaflet::leafletCRS(
  crsClass = "L.Proj.CRS",
  code = "EPSG:2502",
  proj4def = "+proj=tmerc +lat_0=0 +lon_0=69 +k=1 +x_0=500000 +y_0=0 +ellps=krass
              +towgs84=25,-141,-78.5,0,0.35,0.736,0 +units=m +no_defs",
  resolutions = 2^(16:7))

leaflet::leaflet(
  geokz::kaz_adm1_sf |> sf::st_transform(crs = "+proj=longlat +datum=WGS84") |>
                            sf::st_zm(geometry),
  options = leafletOptions(crs = epsg102027)
  ) |>
  leaflet::addPolygons(
    weight = 2,
    color = "grey",
    opacity = 1,
    fillColor = ~pal(as.integer(KATO)),
    fillOpacity = 0.7,
    smoothFactor = 0.5,
    label = ~paste(ADM1_KK, ":", KATO),
    labelOptions = labelOptions(direction = "auto")
    ) |>
  leaflet::addCircleMarkers(
    data = points,
    color = "red",
    radius = 3,
    label = ~paste(branch, ":", name)
    )

}  # The end for {leaflet} package

arodionoff/geokz documentation built on July 1, 2024, 9:02 p.m.