Library

library(bangladesh)
library(dplyr)
## 
## 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.4, PROJ 9.7.0; sf_use_s2() is TRUE
library(tmap)

Data

# Load the district shapefile
district <- get_map("district")

# Filter and transform
district <- district %>%
  filter(District %in% c("Rajshahi"))

# Load the district shapefile
upazila <- get_map("upazila")

# Filter and transform
upazila <- upazila %>%
  filter(Upazila %in% c("Natore Sadar"))

Plot District

# tmap plot
tm_shape(district) +
  tm_polygons(
    col = "gold",
    border.col = "black"
  ) +
  tm_text("District", size = 0.8) +
  tm_title("District of My Choice (Rajshahi)") +
  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.8, col = "gray90")
## 
## ── 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').
## This message is displayed once every 8 hours.

Plot Upazila

# tmap plot
tm_shape(upazila) +
  tm_polygons(
    col = "skyblue",
    border.col = "black"
  ) +
  tm_text("Upazila", size = 0.8) +
  tm_title("Upazila of My Choice (Natore Sadar)") +
  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.8, col = "gray90")
## 
## ── tmap v3 code detected ───────────────────────────────────────────────────────