library(bangladesh)
## Warning: package 'bangladesh' was built under R version 4.5.2
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.5.2
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(sf)
## Linking to GEOS 3.13.1, GDAL 3.11.0, PROJ 9.6.0; sf_use_s2() is TRUE
library(tmap)

# Load all district shapes
districts <- get_map("district")

# Select Khulna District
khulna <- districts %>%
  filter(District == "Khulna") %>%
  st_transform(32646)

# Plot District Map
tm_shape(khulna) +
  tm_polygons(col = "lightpink", border.col = "black") +
  tm_text("District", size = 0.8) +
  tm_title("Map of Khulna District") +
  tm_compass(position = c("left", "bottom"), type = "8star", size = 5) +
  tm_scalebar(position = c("right", "bottom"), text.size = 0.7) +
  tm_grid(lines = TRUE, labels.size = 0.7, col = "gray85")
## 
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [v3->v4] `tm_polygons()`: use 'fill' for the fill color of polygons/symbols
## (instead of 'col'), and 'col' for the outlines (instead of 'border.col').
## [plot mode] fit legend/component: Some legend items or map compoments do not
## fit well, and are therefore rescaled.
## ℹ Set the tmap option `component.autoscale = FALSE` to disable rescaling.
## This message is displayed once every 8 hours.

# Load upazila shapes
upazilas <- get_map("upazila")

# Select Dacope Upazila from Khulna district
dacope <- upazilas %>%
  filter(District == "Khulna" & Upazila == "Dacope") %>%
  st_transform(32646)

# Plot Upazila Map
tm_shape(dacope) +
  tm_polygons(col = "green", border.col = "red") +
  tm_text("Upazila", size = 0.7) +
  tm_title("Map of Dacope Upazila (Khulna District)") +
  tm_compass(position = c("left", "bottom"), type = "8star", size = 4) +
  tm_scalebar(position = c("right", "bottom"), text.size = 0.7) +
  tm_grid(lines = TRUE, labels.size = 0.7, col = "gray85")
## 
## ── tmap v3 code detected ───────────────────────────────────────────────────────
## [plot mode] fit legend/component: Some legend items or map compoments do not
## fit well, and are therefore rescaled.
## ℹ Set the tmap option `component.autoscale = FALSE` to disable rescaling.