The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Introduction to pkmapr

library(pkmapr)

This vignette covers loading boundary data, looking up official names, joining your own data, and producing static and interactive maps.

Installation

Install pkmapr from CRAN:

install.packages("pkmapr")

Or install the development version from GitHub:

remotes::install_github("abdullahumer1101/pkmapr")

Your first map

Retrieve province boundaries and produce a map in two lines:

provinces <- get_provinces()
pk_map(provinces)

Look up names before joining

Official administrative names in the OCHA/HDX data may differ from common spellings. Use pk_dictionary() to confirm names and codes before filtering or joining:

# All provinces with their codes
pk_dictionary("provinces")

# Districts in Punjab
pk_dictionary("districts", province = "Punjab")

# Tehsils in Lahore district
pk_dictionary("tehsils", district = "Lahore")

Join your own data

pk_join() merges a data frame into an sf object by a shared code column, keeping geometries intact:

library(dplyr)

my_data <- data.frame(
  district_code = c("PK603", "PK604"),
  value         = c(42, 37)
)

districts <- get_districts() |>
  pk_join(my_data, by = "district_code")

pk_map(districts, fill = "value", title = "My Values")

Interactive maps

pk_map_interactive() produces a leaflet map with popups:

pk_map_interactive(
  districts,
  fill  = "value",
  popup = c("district_name", "value")
)

Next steps

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.