For the work, we have to load the following libraries:

packages <- c("terra", "tidyverse", "dplyr")

Method

The process requires collecting district wise data on AAY population. The data is available from District statistical handbook which is published yearly. The data is saved in a csv format and merged to the district shapefile. The data is available for 2009,2010,2011 and then from 2018 onwards. The projected data is used for the missing years.

aay <- read.csv("state/assam_district_27_nhm_drnkg_sanit.csv")

districts_27 <- vect("assam_district_27_4326.shp")

length(districts_27)
## [1] 27
distr_nhm_27 <- merge(districts_27, aay, by='OBJECTID')

#user-defined function to rasterise the AAY data 
aay_rasterising <- function(yr){
  var <- rast("state/pop_ind_ppp_2015_UNadj.tif")
  #plot(var)
  aay <- rast(nrow = nrow(var), ncol = ncol(var))
  ext(aay) <- ext(var)
  res(aay) <- res(var)
  crs(aay) <- crs(var)
  #yr <- 2015
  aay <- rasterize(distr_nhm_27, aay, sprintf('X%s',yr))
  plot(aay, main = yr)
  writeRaster(aay,sprintf("outputs_vulnerability/State_aay_%s.tif",yr), overwrite = T)
}
#calling the function
year <- c(2015:2020)
s <- sapply(year, aay_rasterising)

#projecting the AAY population for years 2021 and 2021 using the growth rate of aged population between 2015 and 2020

#projected population for 2021
fact2015 <- rast("outputs_vulnerability/State_aay_2015.tif")
fact2020 <- rast("outputs_vulnerability/State_aay_2020.tif")
factGrowthRate <- ((fact2020 - fact2015)/fact2015)/5
fact2021 <- fact2020 + fact2020*factGrowthRate
plot(fact2021, main = "Projected AAY population 2021")

writeRaster(fact2021 , "outputs_vulnerability/State_aay_2021.tif", overwrite=TRUE)
#projected population for 2022
fact2022 <- fact2021 + fact2021*factGrowthRate
plot(fact2022, main = "Projected AAY population 2022")

writeRaster(fact2022 , "outputs_vulnerability/State_aay_2022.tif", overwrite=TRUE)