library(tmap)
## Warning: package 'tmap' was built under R version 4.5.2
library(bangladesh)
## Warning: package 'bangladesh' was built under R version 4.5.2
division <- get_map("division")
tm_shape(division) +
tm_polygons()

tm_shape(division) +
tm_polygons(fill = "Division")

tm_shape(division) +
tm_polygons(fill = "Division") +
tm_title("Divisions of Bangladesh")

tm_shape(division) +
tm_polygons(fill = "Division") +
tm_title("Administrative Divisions of Bangladesh") +
tm_text("Division")
## [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.

# ------ Add a scale bar ---------
tm_shape(division) +
tm_polygons(fill = "Division") +
tm_title("Administrative Divisions of Bangladesh") +
tm_text("Division") +
tm_compass(position = c("left", "bottom"), type = "8star", size = 5) +
tm_scalebar(position = c("right", "bottom"), text.size = 0.7)
## [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.

tm_shape(division) +
tm_polygons(fill = "Division") +
tm_title("Administrative Divisions of Bangladesh") +
tm_text("Division") +
tm_compass(position = c("left", "bottom"),
type = "8star", size = 5)
## [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.

tm_shape(division) +
tm_polygons(fill = "Division") +
tm_title("Administrative Divisions of Bangladesh") +
tm_text("Division") +
tm_compass(position = c("left", "bottom"), type = "8star", size = 5) +
tm_scalebar(position = c("right", "bottom"), text.size = 0.7)
## [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.

tm_shape(division) +
tm_polygons(fill = "Division") +
tm_title("Administrative Divisions of Bangladesh") +
tm_text("Division") +
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")
## [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.

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.0, PROJ 9.6.0; sf_use_s2() is TRUE
# Load the district shapefile
district <- get_map("district")
# Filter and transform
flood_zone <- district %>%
filter(District %in% c("Khulna", "Satkhira"))
# tmap plot
tm_shape(flood_zone) +
tm_polygons(
col = "red",
border.col = "black"
) +
tm_text("District", size = 0.8) +
tm_title("Flood-Prone Districts (Khulna & Satkhira)") +
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').
## [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.

library(bangladesh)
library(dplyr)
library(sf)
# Load the district shapefile
district <- get_map("district")
# Filter and transform
flood_zone <- district %>%
filter(District %in% c("Khulna", "Satkhira")) %>%
st_transform(32646)
# tmap plot
tm_shape(flood_zone) +
tm_polygons(
col = "red",
border.col = "black"
) +
tm_text("District", size = 0.8) +
tm_title("Flood-Prone Districts (Khulna & Satkhira)") +
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 ───────────────────────────────────────────────────────
## [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.
