Point pattern map
# options(timeout = max(300, getOption(“timeout”)))
install.packages(“sf”, dep = TRUE)
library(sf)
help(package = “sf”)
GE_BDHS17 <- read_sf(“C:\\Users\\ASUS_VivoBook\\Desktop\\BDGE7SFL\\BDGE7SFL.shp”)
class(GE_BDHS17)
head(GE_BDHS17)
dim(GE_BDHS17)
GE_BDHS17 <- GE_BDHS17[ , c(‘DHSCLUST’, ‘ADM1NAME’,
‘SOURCE’, ‘URBAN_RURA’,
‘LONGNUM’, ‘LATNUM’ ) ]
#GE_BDHS1799 <- GE_BDHS17[ 1:3, 2:3 ]
class(GE_BDHS17); head(GE_BDHS17); nrow(GE_BDHS17)
names( GE_BDHS17 ) <- tolower( names( GE_BDHS17 ) )
library(tmap) # install.packages(“tmap”, dep = T)
tmap_mode(“view”) # tmap mode set to interactive viewing [ ?tmap_mode ]
tm_shape(GE_BDHS17) +
tm_dots(col = “blue”, # ?tm_dots ?mean
size = 0.1,
shape = 11)
div_map <- read_sf( “C:/Users/ASUS_VivoBook/Desktop/BD_shp/adm1.shp” )
class(div_map); head(div_map); nrow(div_map) #This object is of class
# div_map_geom <- st_geometry(div_map)
# div_map_geom[[1]]
par(mar = c(0,0,1,0)) # ?par
plot(div_map_geom)
dist_map <- read_sf( “C:/Users/ASUS_VivoBook/Desktop/BD_shp/adm2.shp” )
class(dist_map); head(dist_map); dim(dist_map) #This object is of class
tmap_mode(“plot”)
tm_shape(div_map) +
tm_borders(lwd=2) +
tm_shape(dist_map) +
tm_borders(lwd=2) +
tm_shape(GE_BDHS17) +
tm_dots(col = “blue”,
size = 0.09,
shape = 21) # ?points
Solution-2
library(sf)
div_map <- read_sf(“E:\\Department\\Aminur Sir\\Point pattern map BDHS 2017-18\\BD_shp\\adm1.shp”)
View(div_map)
library(readr)
library(readxl)
PopPerDiv <- read_csv(“E:/Department/Aminur Sir/4/census2022bgd.csv”)
View(PopPerDiv)
names(div_map)
names(div_map)[3] = “Division”
library(dplyr)
PopPerDiv_GE_BD <- left_join(div_map,PopPerDiv)
View(PopPerDiv_GE_BD)
library(tmap)
tm_shape(PopPerDiv_GE_BD)+
tm_fill(“male_per”)+
tm_borders(col = “black”, lwd = 0.02, alpha = 0.1)+
tm_text(“Division”, size=”AREA”, scale=1.2)
tm_shape(PopPerDiv_GE_BD)+
tm_fill(“female_per”)+
tm_borders(col = “black”, lwd = 0.02, alpha = 0.1)+
tm_text(“Division”, size=”AREA”, scale=1.2)
