This work uses the age and sex structure unconstrained data (https://hub.worldpop.org/geodata/listing?id=30) for India from Worldpop.org (summary note : https://docs.google.com/document/d/1VVjMFbYM0RsmxRDEfZsbHHOJeqBjkTu1SSpoinmWk1Q/edit#heading=h.w4e1uk1k1taa). The data from world pop is cropped to state boundary.
For the work, we have to load the following libraries:
packages <- c("terra")
A for-loop extracts the image files of male and female for specific year. For each year, the male and female populations of different age groups are added up to get a yearly single image representing the male and female population, respectively. the cumulation images are saved seperately for each year.
year <- 2015:2020
for(i in year){
#i <- 2015
s_files <- dir("state/agesexstructure")
split <- strsplit(s_files,"_")
#matching for the year
state_1 <- match(unlist(split), sprintf("%s.tif",i))
pos <- which(!is.na(state_1))
pos <- round(pos/4,0)
s_files <- s_files[pos]
#matching for the sex
split <- strsplit(s_files,"_")
state_1 <- match(unlist(split), "f")
pos_1 <- which(!is.na(state_1))
pos_1 <- round(pos_1/4,0)
state_2 <- match(unlist(split), "m")
pos_2 <- which(!is.na(state_2))
pos_2 <- round(pos_2/4,0)
s_files_f <- s_files[pos_1]
s_files_m <- s_files[pos_2]
file_path <- "state/agesexstructure"
pop_f <- rast(sprintf("%s/%s",file_path,s_files_f))
pop_female <- app(pop_f, "sum")
plot(pop_female, main = sprintf("Female_%s",i))
file_path <- "state/agesexstructure"
pop_m <- rast(sprintf("%s/%s",file_path,s_files_m))
pop_male <- app(pop_m, "sum")
plot(pop_male, main = sprintf("Male_%s",i))
writeRaster(pop_female,sprintf("outputs_vulnerability/State_femalepop_%s.tif",i), overwrite = T)
writeRaster(pop_male,sprintf("outputs_vulnerability/State_malepop_%s.tif",i), overwrite = T)
}
A for-lopp runs through the cumulative male and female images for each year and finds the sex ratio.
#Calculating the sex ratio for the years
year <- 2015:2020
for(i in year){
#i <- 2015
f <- rast(sprintf("outputs_vulnerability/State_femalepop_%s.tif",i))
m <- rast(sprintf("outputs_vulnerability/State_malepop_%s.tif",i))
sr <- (1000*f)/m
plot(sr, main = sprintf("SexRatio_%s",i))
writeRaster(sr,sprintf("outputs_vulnerability/State_sr_%s.tif",i), overwrite = T)
}
The growth rate of the sex ratio calculated using the sex ration of 2015 and 2021 is used to project the sex ratio from 2020 for 2021 and 2022.
#projecting the sex ratio for years 2021 and 2021 using the growth rate of sex ratio between 2015 and 2020
#projected population for 2021
sexratio2015 <- rast("outputs_vulnerability/State_sr_2015.tif")
sexratio2020 <- rast("outputs_vulnerability/State_sr_2020.tif")
SRGrowthRate <- ((sexratio2020 - sexratio2015)/sexratio2015)/5
SR2021 <- sexratio2020 + sexratio2020*SRGrowthRate
plot(SR2021, main = "Projected Sex Ratio 2021")
writeRaster(SR2021 , "state/State_sr_2021.tif", overwrite=TRUE)
#projected population for 2022
SR2022 <- SR2021 + SR2021*SRGrowthRate
plot(SR2022, main = "Projected Sex Ratio 2022")
writeRaster(SR2022 , "state/State_sr_2022.tif", overwrite=TRUE)