Untitled
unknown
plain_text
10 months ago
2.9 kB
5
Indexable
###01
library(sf)
library(tmap)
# load BDHS clusters shapefile
GE_BDHS17 <- read_sf("D:\\Academic\\4H\\410\\408\\problem 1-6\\problem 1-6\\data\\BDGE7SFL\\BDGE7SFL.shp")
tm_shape(GE_BDHS17) +
tm_dots()
# load division shapefile
div_map <- read_sf( "C:\\Users\\ASUS_VivoBook\\Desktop\\408 (practical)\\problem 1-6\\P-1\\Data\\BD_shp\\adm1.shp" )
tm_shape(div_map) +
tm_borders()
bd_map <- tm_shape(div_map) +
tm_borders(lwd=2) +
tm_shape(GE_BDHS17) +
tm_dots(col = "blue")
tmap_save(bd_map,"C:\\Users\\ASUS_VivoBook\\Desktop\\408 (practical)\\problem 1-6\\P-1\\Output\\map3.png")
###02
cSec17 <- read.csv("C:\\Users\\ASUS_VivoBook\\Desktop\\408 (practical)\\problem 1-6\\P-2\\data\\cSec.csv")
install.packages("sf")
library(sf)
locations_longlat <- read_sf( "C:\\Users\\ASUS_VivoBook\\Desktop\\408 (practical)\\problem 1-6\\P-1\\Data\\BDGE7SFL\\BDGE7SFL.shp" )
library(dplyr)
cSec_longlatBDHS17 <- left_join(locations_longlat,
cSec17,
join_by(DHSCLUST == dhsclust))
# load division shapefile
div_map <- read_sf( "C:\\Users\\ASUS_VivoBook\\Desktop\\408 (practical)\\problem 1-6\\P-1\\Data\\BD_shp\\adm1.shp" )
install.packages("tmap")
library(tmap)
Output <- tm_shape(div_map) +
tm_borders() +
tm_shape(cSec_longlatBDHS17) +
tm_dots(col = "cSecRate", size = 0.3)
tmap_save(Output,"C:\\Users\\ASUS_VivoBook\\Desktop\\408 (practical)\\problem 1-6\\P-2\\Output\\CsecMap.png")
###03
library(sf)
div_map<-read_sf("C:\\Users\\ASUS_VivoBook\\Desktop\\408 (practical)\\problem 1-6\\P-1\\Data\\BD_shp\\adm1.shp")
divpoper_BD<-read.csv("C:/Users/ASUS_VivoBook/Desktop/408 (practical)/problem 1-6/P-3/Data/maleFemalePer.csv")
library(dplyr)
divpoper_GE_BD <- left_join(div_map,divpoper_BD)
library(tmap)
#Male
Male<- tm_shape(divpoper_GE_BD)+
tm_polygons("Male.per")+
tm_borders()
#Female
Female<- tm_shape(divpoper_GE_BD)+
tm_polygons("Female.per")+
tm_borders()
###04
library(sf)
div_map<-read_sf("C:/Users/ASUS_VivoBook/Desktop/408 (practical)/problem 1-6/data/BD_shp/adm1.shp")
# Create divisional area in km2
div_map$Shape_Areakm2 <- div_map$Shape_Area * 10000
divpoper_BD<-read.csv("C:/Users/ASUS_VivoBook/Desktop/408 (practical)/problem 1-6/data/maleFemalePop.csv")
library(dplyr)
divpoper_GE_BD<-left_join(div_map,divpoper_BD)
divpoper_GE_BD$density<- (divpoper_GE_BD$Total.population%/%divpoper_GE_BD$Shape_Area)
library(tmap)
#Percentage
Percentage<- tm_shape(divpoper_GE_BD)+
tm_polygons("Percentage")+
tm_borders(col = "black")
tmap_save(Percentage,"E:\\Class\\4H\\408\\Practical\\P-4\\Output\\Percentage.png")
#Density
Density<- tm_shape(divpoper_GE_BD)+
tm_polygons("density")+
tm_borders(col = "black")
tmap_save(Density,"E:\\Class\\4H\\408\\Practical\\P-4\\Output\\Density.png")
Editor is loading...
Leave a Comment