The goal of mapindia is to simplify mapping of the Indian subcontinent. It has convenient functions for plotting choropleths, visualizing spatial data, and handling state/district codes.
Note: The 3-digit district codes were merged with the 2-digit state codes to create a 5-digit district code.
To install mapindia from CRAN:
install.packages("mapindia")
You can install the development version of mapindia from GitHub with:
# install.packages("pak")
::pak("shubhamdutta26/mapindia") pak
library(mapindia)
Plot basic maps of the Indian subcontinent with states and districts:
library(mapindia)
library(ggplot2)
library(cowplot)
<- plot_india("states") +
states geom_sf(fill= "antiquewhite") +
theme(panel.grid.major =
element_line(color = gray(.5), linetype = "dashed", linewidth = 0.2),
panel.background = element_rect(fill = "aliceblue"))
<- plot_india("districts") +
districts geom_sf(fill= "gray") +
theme(panel.grid.major =
element_line(color = gray(.5), linetype = "dashed", linewidth = 0.2),
panel.background = element_rect(fill = "aliceblue"))
::plot_grid(states, districts, nrow = 1) cowplot
Visualize zones such as the Central or Eastern Zonal Councils:
<- plot_india("states", include = .central, exclude = "UK", labels = TRUE) +
central geom_sf(fill= "antiquewhite")
<- plot_india("states", include = .east, labels = FALSE)
east
::plot_grid(central, east, nrow = 1) cowplot
Visualize individual states such as the West Bengal or Tamil Nadu:
<- plot_india("districts", include = "MH")
mh
<- plot_india("state", include = "Tamil Nadu", labels = FALSE)
tn
::plot_grid(mh, tn, nrow = 1) cowplot
Use your data for visualizations as well:
<- plot_india("states", data = statepop, values = "pop_2011") +
statepop2011 scale_fill_continuous(low = "blue", high = "yellow", guide = "none")
<- plot_india("districts", data = wb_2011, values = "pop_2011", include = "WB") +
wbpop2011 scale_fill_continuous(low = "green", high = "red", guide = "none")
::plot_grid(statepop2011, wbpop2011, nrow = 1) cowplot