diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9b17743 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata + +*.Rproj + +data/* diff --git a/00_Data_Processing.R b/00_Data_Processing.R index 787ecfa..89e27f4 100644 --- a/00_Data_Processing.R +++ b/00_Data_Processing.R @@ -1,4 +1,4 @@ -# Data exploration workflow for dataset recived +# Data exploration workflow for dataset received #load packages library(sf) @@ -9,21 +9,41 @@ library(tidyverse) options(scipen = 999) # turn off scientific notation for all variables #Specify Drive Path -drive_path <- "//Internal_Path/" -input_path <- paste0(drive_path, "Input_Data/Surveys/") -output_path <- paste0(drive_path, "/Output_Data/") -shapefile_path <- paste0(drive_path, "Input_Data/Shapefiles/") +drive_path <- "./data" +input_path <- file.path(drive_path, "MNSO-Data") +output_path <- file.path(drive_path, "Output_Data") +shapefile_path <- file.path(drive_path, "Shapefiles") #Load datasets -mphc_2018 <- read_dta(paste0(input_path, "mphc2018Data_AllRegions.dta")) -mphc_structures_2018 <- read_dta(paste0(input_path, "mphc2018Data_structures.dta")) -ICT_data <- read_dta(paste0(input_path, "ICT Listing WorldPop.dta")) -IHS6_data <- read_dta(paste0(input_path, "IHS6 Listing WorldPop.dta")) -Naca_data <- read_dta(paste0(input_path, "Naca Listing WorldPop.dta")) -ea <- st_read(file.path(shapefile_path, "2018_MPHC_EAs_Final_for_Use_Corrected.shp")) -mphc_structures_2018 <- st_read(paste0(output_path, "mphc_structures_points.gpkg")) -dhs_data <- read_dta(paste0(input_path, "MDHS_2024_NoDZLK_anonymized.dta")) -dhs_listing <- read_dta(paste0(input_path, "FINAL MDHS LISTING DATA_Annon.dta")) +mphc_2018 <- read_dta(file.path(input_path, "mphc2018Data_AllRegions.dta")) +mphc_structures_2018 <- read_dta(file.path(input_path, "mphc2018Data_structures.dta")) +ICT_data <- read_dta(file.path(input_path, "ICT Listing WorldPop.dta")) +IHS6_data <- read_dta(file.path(input_path, "IHS6 Listing WorldPop.dta")) +Naca_data <- read_dta(file.path(input_path, "Naca Listing WorldPop.dta")) +ea <- st_read(file.path(shapefile_path, "2018_MPHC_EAs_Final_for_Use.shp")) # replaces "2018_MPHC_EAs_Final_for_Use_Corrected.shp" +dhs_data <- read_dta(file.path(input_path, "MDHS_2024_NoDZLK_anonymized.dta")) +dhs_listing <- read_dta(file.path(input_path, "FINAL MDHS LISTING DATA_Annon.dta")) + +mphc_structures_2018_filepath <- file.path( + output_path, "mphc_structures_points.gpkg") + +if (!file.exists(mphc_structures_2018_filepath)) { + #Structures + #Convert to sf object + mphc_structures_sf <- mphc_structures_2018 |> + drop_na(st_longitude, st_latitude) |> + st_as_sf(coords = c("st_longitude", "st_latitude")) + + #set the spatial reference + st_crs(mphc_structures_sf ) <- 4326 + + # Write to GPKG file + st_write(mphc_structures_sf , + dsn = file.path(output_path, "mphc_structures_points.gpkg"), + driver = "GPKG", + delete_layer = TRUE) +} +mphc_structures_2018 <- st_read(file.path(output_path, "mphc_structures_points.gpkg")) # Write each data as a shapefile ----------------------------------------- @@ -41,20 +61,7 @@ dhs_listing <- read_dta(paste0(input_path, "FINAL MDHS LISTING DATA_Annon.dta")) # driver = "GPKG", # delete_layer = TRUE) # overwrite if layer already exists # -# #Structures -# #Convert to sf object -# mphc_structures_sf <- mphc_structures_2018 |> -# drop_na(st_longitude, st_latitude) |> -# st_as_sf(coords = c("st_longitude", "st_latitude")) -# -# #set the spatial reference -# st_crs(mphc_structures_sf ) <- 4326 -# -# # Write to GPKG file -# st_write(mphc_structures_sf , -# dsn = file.path(output_path, "mphc_structures_points.gpkg"), -# driver = "GPKG", -# delete_layer = TRUE) + # # #ICT # ICT_sf <- ICT_data |> @@ -179,7 +186,7 @@ mphc_pop_per_ea <- mphc_2018 |> female_count = sum(p03 == 2, na.rm = TRUE)) -#Create a bin for each age catgeory +#Create a bin for each age category age_summary <- mphc_2018 |> mutate(age_group = case_when( p05 < 1 ~ "age_group_01_less", #less than 1 @@ -333,13 +340,13 @@ combined_data <- combined_data |> #Write to file -write.csv(combined_data, paste0(output_path, "summarized_survey_data.csv"), row.names = F) +write.csv(combined_data, file.path(output_path, "summarized_survey_data.csv"), row.names = F) #join combined data to EA shapefile and export #Join to ea data combined_data <- combined_data |> - mutate(EA_CODE = as.character(EA_CODE)) #convert EA code to interger + mutate(EA_CODE = as.character(EA_CODE)) #convert EA code to integer #select hh size hh_size <- combined_data |> @@ -352,7 +359,7 @@ hh_ea <- hh_ea |> select(EA_CODE, mphc_total_pop, hh_size) #write to file -st_write(hh_ea, paste(output_path, "hh_size_data.shp")) +st_write(hh_ea, file.path(output_path, "hh_size_data.shp")) diff --git a/00_Data_Processing2.R b/00_Data_Processing2.R index b379a02..67b2b20 100644 --- a/00_Data_Processing2.R +++ b/00_Data_Processing2.R @@ -1,4 +1,6 @@ # Summarizing data at the EA level using EA-CODE and Spatial location of the points +# Should be run after 00_Data_Processing.R +# NOTE: This is currently omitting the Zomba, Malemia and DHS Segmented data due to availability. #load packages library(sf) @@ -7,27 +9,25 @@ library(haven) library(tidyverse) #library(foreign) +source("utils.R") + options(scipen = 999) # turn off scientific notation for all variables #Specify Drive Path -drive_path <- "//Internal_Path/" -input_path <- paste0(drive_path, "Input_Data/Surveys/") -output_path <- paste0(drive_path, "/Output_Data/") -shapefile_path <- paste0(drive_path, "Input_Data/Shapefiles/") +drive_path <- "./data" +input_path <- file.path(drive_path, "MNSO-Data") +output_path <- file.path(drive_path, "Output_Data") +shapefile_path <- file.path(drive_path, "Shapefiles") #Load datasets -mphc_2018 <- read_dta(paste0(input_path, "mphc2018Data_AllRegions.dta")) -#mphc_structures_2018 <- read_dta(paste0(input_path, "mphc2018Data_structures.dta")) -ICT_data <- read_dta(paste0(input_path, "ICT Listing WorldPop.dta")) -IHS6_data <- read_dta(paste0(input_path, "IHS6 Listing WorldPop.dta")) -Naca_data <- read_dta(paste0(input_path, "Naca Listing WorldPop.dta")) -ea <- st_read(file.path(shapefile_path, "2018_MPHC_EAs_Final_for_Use_Corrected.shp")) -#mphc_structures_2018 <- st_read(paste0(output_path, "mphc_structures_points.gpkg")) -dhs_data <- read_dta(paste0(input_path, "MDHS_2024_NoDZLK_anonymized.dta")) -dhs_listing <- read_dta(paste0(input_path, "FINAL MDHS LISTING DATA_Annon.dta")) -dhs_file <- read.csv(paste0(input_path, "DHS_Segmented_File.csv")) -zomba_data <- read.csv(paste0(output_path, "zomba_rbind_data.csv")) -malemia_data <- read.csv(paste0(input_path, "malemia_hh_without_IDs.csv")) +mphc_2018 <- read_dta(file.path(input_path, "mphc2018Data_AllRegions.dta")) +ICT_data <- read_dta(file.path(input_path, "ICT Listing WorldPop.dta")) +IHS6_data <- read_dta(file.path(input_path, "IHS6 Listing WorldPop.dta")) +Naca_data <- read_dta(file.path(input_path, "Naca Listing WorldPop.dta")) +ea <- st_read(file.path(shapefile_path, "2018_MPHC_EAs_Final_for_Use.shp")) # replaces "2018_MPHC_EAs_Final_for_Use_Corrected.shp" +dhs_data <- read_dta(file.path(input_path, "MDHS_2024_NoDZLK_anonymized.dta")) +dhs_listing <- read_dta(file.path(input_path, "FINAL MDHS LISTING DATA_Annon.dta")) + ##################################################################################### #################################################################################### @@ -41,7 +41,7 @@ mphc_2018 <- mphc_2018 %>% mphc_2018_no_gps <- mphc_2018 %>% filter(is.na(hh_longitude) | is.na(hh_latitude)) -#Add additonal digits to EA and TA code +#Add additional digits to EA and TA code mphc_2018_no_gps <- mphc_2018_no_gps %>% mutate(new_ta = str_pad(ta, width = 2, pad = 0), @@ -67,7 +67,7 @@ mphc_pop_no_gps <- mphc_2018_no_gps %>% female_count = sum(p03 == 2, na.rm = TRUE)) -#Create a bin for each age catgeory +#Create a bin for each age category age_summary_no_gps <- mphc_2018_no_gps %>% mutate(age_group = case_when( p05 < 1 ~ "age_group_01_less", #less than 1 @@ -110,42 +110,47 @@ mphc_pop_no_gps <- mphc_pop_no_gps %>% # ============================================================== ---------- -# Convert remaining mphc_2018 data to shapefiles +#load dataset +mphc_2018_sf_filepath <- file.path(output_path, "mphc_2018_sf_ea.gpkg") +if (!file.exists(mphc_2018_sf_filepath)) { + print("The geopackage version of mphc_2018 is not available, creating dataframe and saving to disk.") + + # Convert remaining mphc_2018 data to shapefiles + + #Convert to sf object + mphc_2018_sf <- mphc_2018 %>% + drop_na(hh_longitude, hh_latitude) %>% + st_as_sf(coords = c("hh_longitude", "hh_latitude")) + + #set the spatial reference + st_crs(mphc_2018_sf) <- 4326 -# #Convert to sf object -# mphc_2018_sf <- mphc_2018 %>% -# drop_na(hh_longitude, hh_latitude) %>% -# st_as_sf(coords = c("hh_longitude", "hh_latitude")) -# -# #set the spatial reference -# st_crs(mphc_2018_sf) <- 4326 + #Fix corrupt geometries + st_make_valid(ea) -#Fix corrupt geometries -#st_make_valid(ea) + #Turn off invalid geometries + sf::sf_use_s2(FALSE) -#Turn off invalid geometries -# sf::sf_use_s2(FALSE) + #transform + mphc_2018_sf <- st_transform(mphc_2018_sf, crs = st_crs(ea)) -#transform -# mphc_2018_sf <- st_transform(mphc_2018_sf, crs = st_crs(ea)) + # EA Nearest Neighbor Assignment + nearest_indices <- st_nearest_feature(mphc_2018_sf, ea) -# EA Nearest Neighbor Assignment -# nearest_indices <- st_nearest_feature(mphc_2018_sf, ea) + # Extract the EA_CODE of the nearest polygons + nearest_ids <- ea$EA_CODE[nearest_indices] -# Extract the EA_CODE of the nearest polygons -# nearest_ids <- ea$EA_CODE[nearest_indices] + # Add the EA_CODE to data + mphc_2018_sf$EA_CODE <- nearest_ids -# Add the EA_CODE to data -# mphc_2018_sf$EA_CODE <- nearest_ids - -#Write to file -#st_write(mphc_2018_sf , -# dsn = file.path(output_path, "mphc_2018_sf_ea.gpkg"), -# driver = "GPKG", -# delete_layer = TRUE) - -#load dataset -mphc_2018_sf <- st_read(paste0(output_path, "mphc_2018_sf_ea.gpkg")) + #Write to file + st_write(mphc_2018_sf , + dsn = file.path(output_path, "mphc_2018_sf_ea.gpkg"), + driver = "GPKG", + delete_layer = TRUE + ) +} +mphc_2018_sf <- st_read(mphc_2018_sf_filepath) #convert to dataframe mphc_2018_df <- mphc_2018_sf %>% @@ -159,6 +164,52 @@ mphc_2018_df <- mphc_2018_df %>% #check the summary of gps accuracy summary(mphc_2018_df$hh_gps_accuracy) + +# #Fix corrupt geometries +# st_make_valid(ea) + +# #Turn off invalid geometries +# sf::sf_use_s2(FALSE) + +# #transform +# mphc_2018_sf <- st_transform(mphc_2018_sf, crs = st_crs(ea)) + +# # EA Nearest Neighbor Assignment +# nearest_indices <- st_nearest_feature(mphc_2018_sf, ea) + +# # Extract the EA_CODE of the nearest polygons +# nearest_ids <- ea$EA_CODE[nearest_indices] + +# # Add the EA_CODE to data +# mphc_2018_sf$EA_CODE <- nearest_ids + +# #Write to file +# st_write(mphc_2018_sf , +# dsn = file.path(output_path, "mphc_2018_sf_ea.gpkg"), +# driver = "GPKG", +# delete_layer = TRUE +# ) + +# #load dataset +# #mphc_2018_sf <- st_read(file.path(output_path, "mphc_2018_sf_ea.gpkg")) + +# #convert to dataframe +# mphc_2018_df <- mphc_2018_sf %>% +# as_tibble() + +# #check the summary of gps accuracy +# summary(mphc_2018_df$hh_gps_accuracy) + +# # NOTE: ONS CHANGE: Adding a 'hh_count' column of 1 per row. This is a required +# # column below but is not in the source data. +# # This change assumes that each row corresponds to a single resident of Malawi in +# # the census records. +# # Justification: total rows in source data is 17,563,749, matching the published +# # population count for the census. Also this replicates the logic of the no_gps +# # processing above. +# mphc_2018_df <- mphc_2018_df %>% +# mutate(hh_count = 1) # Individual observation + # Summarize data base on their spatial location mphc_2018_pop_spatial <- mphc_2018_df %>% @@ -543,27 +594,43 @@ sum(Naca_data$hh_count) ##################################################################################### #################################################################################### ######### PROCESS DHS Listing DATA ################################################ -#Not segmented clusters -unique(dhs_file$Cluster.Segmented) - -#Get non-segmented cluster -non_seg_cluster <- dhs_file %>% - filter(grepl("^no\\b", Cluster.Segmented, ignore.case = TRUE)) +# Data sent by NSO was "MDHS 2024 HH_Listing_EA.xlxs" which is in "MNSO-Data". This +# file was converted to csv, called "DHS_Segmented_File.csv" and added to Output_data -#Unique cluster id -unique(non_seg_cluster$DHScluster) - -# Clusters in non_seg_cluster and not present in dhs listing -missing_clusters <- setdiff(unique(non_seg_cluster$DHScluster), unique(dhs_listing$QHCLUST)) -missing_clusters - -#Add a new column to data called hh_count -dhs_listing <- dhs_listing %>% - mutate(hh_count = 1) +dhs_file_path <- file.path(input_path, "DHS_Segmented_File.csv") +if (!file.exists(dhs_file_path)) { + print("'DHS_Segmented_File.csv' cannot be found. Skipping processing of this data.") + + #Add a new column to data called hh_count + dhs_listing <- dhs_listing %>% + mutate(hh_count = 1) + +} else { + dhs_file <- read.csv(dhs_file_path) ## FILE MISSING! + + #Not segmented clusters + unique(dhs_file$Cluster.Segmented) + + #Get non-segmented cluster + non_seg_cluster <- dhs_file %>% + filter(grepl("^no\\b", Cluster.Segmented, ignore.case = TRUE)) + + #Unique cluster id + unique(non_seg_cluster$DHScluster) + + # Clusters in non_seg_cluster and not present in dhs listing + missing_clusters <- setdiff(unique(non_seg_cluster$DHScluster), unique(dhs_listing$QHCLUST)) + missing_clusters + + #Add a new column to data called hh_count + dhs_listing <- dhs_listing %>% + mutate(hh_count = 1) + + # Subset dhs_listing using the DHScluster IDs in non_seg_cluster + dhs_listing <- dhs_listing %>% + filter(QHCLUST %in% unique(non_seg_cluster$DHScluster)) -# Subset dhs_listing using the DHScluster IDs in non_seg_cluster -dhs_listing <- dhs_listing %>% - filter(QHCLUST %in% unique(non_seg_cluster$DHScluster)) +} #Summarize total number of hhold per dhs cluster dhs_hh_summary <- dhs_listing %>% @@ -635,7 +702,7 @@ dhs_hh_count<- dhs_centroids_sf %>% ##################################################################################### #################################################################################### ######### PROCESS DHS SUrvey DATA ################################################ -dhs_data <- read_dta(paste0(input_path, "MDHS_2024_NoDZLK_anonymized.dta")) +dhs_data <- read_dta(file.path(input_path, "MDHS_2024_NoDZLK_anonymized.dta")) #Calculate hh size per hh dhs_size <- dhs_data %>% @@ -720,94 +787,116 @@ dhs_hh_size<- dhs_centroids_sf %>% #################################################################################### ######### PROCESS ZOMBA DISTRICT DATA ################################################ -#Add a new column to data called hh_count -zomba_data <- zomba_data %>% - mutate(hh_count = 1) - -#Convert to sf object -zomba_sf <- zomba_data %>% - drop_na(gps_longitude, gps_latitude) %>% - st_as_sf(coords = c("gps_longitude", "gps_latitude")) - -# #set the spatial reference -st_crs(zomba_sf) <- 4326 - -#transform -zomba_sf <- st_transform(zomba_sf, crs = st_crs(ea)) - -# EA Nearest Neighbor Assignment -nearest_indices <- st_nearest_feature(zomba_sf, ea) +# NSO has given 14 csvs that need to be rbound - function in utils.R +rbind_zomba_csvs( + csv_dir = file.path(input_path, "zomba_csv"), + output_file = file.path(output_path,"zomba_rbind_data.csv") +) -# Extract the EA_CODE of the nearest polygons -nearest_ids <- ea$EA_CODE[nearest_indices] - -# Add the EA_CODE to data -zomba_sf$EA_CODE <- nearest_ids +zomba_data_path <- file.path(output_path, "zomba_rbind_data.csv") -#Write to file -#st_write(zomba_sf , -#dsn = file.path(output_path, "zomba_point.gpkg"), -#driver = "GPKG", -#delete_layer = TRUE) - -#convert data to tibble -zomba_tibble <- zomba_sf %>% - as_tibble() - -#Summarize data -zomba_tibble <- zomba_tibble %>% - group_by(EA_CODE) %>% - summarise(zomba_hh_count = sum(hh_count, na.rm = T), - zomba_pop = sum(household_size, na.rm = T)) %>% - ungroup() +if (file.exists(zomba_data_path)){ + zomba_data <- read.csv(zomba_data_path) + + #Add a new column to data called hh_count + zomba_data <- zomba_data %>% + mutate(hh_count = 1) + + #Convert to sf object + zomba_sf <- zomba_data %>% + drop_na(gps_longitude, gps_latitude) %>% + st_as_sf(coords = c("gps_longitude", "gps_latitude")) + + # #set the spatial reference + st_crs(zomba_sf) <- 4326 + + #transform + zomba_sf <- st_transform(zomba_sf, crs = st_crs(ea)) + + # EA Nearest Neighbor Assignment + nearest_indices <- st_nearest_feature(zomba_sf, ea) + + # Extract the EA_CODE of the nearest polygons + nearest_ids <- ea$EA_CODE[nearest_indices] + + # Add the EA_CODE to data + zomba_sf$EA_CODE <- nearest_ids + + #Write to file + #st_write(zomba_sf , + #dsn = file.path(output_path, "zomba_point.gpkg"), + #driver = "GPKG", + #delete_layer = TRUE) + + #convert data to tibble + zomba_tibble <- zomba_sf %>% + as_tibble() + + #Summarize data + zomba_tibble <- zomba_tibble %>% + group_by(EA_CODE) %>% + summarise(zomba_hh_count = sum(hh_count, na.rm = T), + zomba_pop = sum(household_size, na.rm = T)) %>% + ungroup() + + print("Zomba data processed") +} else { + print("The Zomba data cannot be found. Skipping processing of this data for now.") +} ##################################################################################### #################################################################################### ######### PROCESS MALEMA DISTRICT DATA ################################################ -#Add a new column to data called hh_count -malemia_data <- malemia_data %>% - mutate(hh_count = 1) - -#Convert to sf object -malemia_sf <- malemia_data %>% - drop_na(hh_longitude, hh_latitude) %>% - st_as_sf(coords = c("hh_longitude", "hh_latitude")) - -# #set the spatial reference -st_crs(malemia_sf) <- 4326 - -#transform -malemia_sf <- st_transform(malemia_sf, crs = st_crs(ea)) - -# EA Nearest Neighbor Assignment -nearest_indices <- st_nearest_feature(malemia_sf, ea) - -# Extract the EA_CODE of the nearest polygons -nearest_ids <- ea$EA_CODE[nearest_indices] - -# Add the EA_CODE to data -malemia_sf$EA_CODE <- nearest_ids - -#Write to file -#st_write(malemia_sf , -#dsn = file.path(output_path, "malemia_point.gpkg"), -#driver = "GPKG", -#delete_layer = TRUE) - -#convert data to tibble -malemia_tibble <- malemia_sf %>% - as_tibble() - -#Summarize data -malemia_tibble <- malemia_tibble %>% - group_by(EA_CODE) %>% - summarise(malemia_hh_count = sum(hh_count, na.rm = T)) %>% - #zomba_pop = sum(household_size, na.rm = T)) %>% - ungroup() - - +malemia_data_path <- file.path(input_path, "malemia_hh_without_IDs.csv") +if (file.exists(malemia_data_path)) { + malemia_data <- read.csv(malemia_data_path) + + #Add a new column to data called hh_count + malemia_data <- malemia_data %>% + mutate(hh_count = 1) + + #Convert to sf object + malemia_sf <- malemia_data %>% + drop_na(hh_longitude, hh_latitude) %>% + st_as_sf(coords = c("hh_longitude", "hh_latitude")) + + # #set the spatial reference + st_crs(malemia_sf) <- 4326 + + #transform + malemia_sf <- st_transform(malemia_sf, crs = st_crs(ea)) + + # EA Nearest Neighbor Assignment + nearest_indices <- st_nearest_feature(malemia_sf, ea) + + # Extract the EA_CODE of the nearest polygons + nearest_ids <- ea$EA_CODE[nearest_indices] + + # Add the EA_CODE to data + malemia_sf$EA_CODE <- nearest_ids + + #Write to file + #st_write(malemia_sf , + #dsn = file.path(output_path, "malemia_point.gpkg"), + #driver = "GPKG", + #delete_layer = TRUE) + + #convert data to tibble + malemia_tibble <- malemia_sf %>% + as_tibble() + + #Summarize data + malemia_tibble <- malemia_tibble %>% + group_by(EA_CODE) %>% + summarise(malemia_hh_count = sum(hh_count, na.rm = T)) %>% + #zomba_pop = sum(household_size, na.rm = T)) %>% + ungroup() + print("Malemia data processed") +} else { + print("Malemia data cannot be found. Skipping processing of this for now.") +} ############################################################################ @@ -820,9 +909,25 @@ combined_data <- mphc_rbind %>% left_join(IHS_rbind, by = "EA_CODE") %>% left_join(Naca_rbind, by = c("EA_CODE" ="EA_Number")) %>% left_join(dhs_hh_size, by = "EA_CODE") %>% - left_join(dhs_hh_count, by = "EA_CODE") %>% - left_join(zomba_tibble, by = "EA_CODE") %>% + left_join(dhs_hh_count, by = "EA_CODE") + +if (exists("zomba_tibble")) { + combined_data <- combined_data %>% + left_join(zomba_tibble, by = "EA_CODE") +} else { + # add dummy placeholder column full of NAs + combined_data <- combined_data %>% + mutate(malemia_hh_count = NA) +} + +if (exists("malemia_tibble")) { + combined_data <- combined_data %>% left_join(malemia_tibble, by = "EA_CODE") +} else { + # add dummy placeholder column full of NAs + combined_data <- combined_data %>% + mutate(zomba_hh_count = NA) +} #create observed hh_count based on priority conditions combined_data <- combined_data %>% @@ -850,17 +955,19 @@ combined_data <- combined_data %>% select(EA_CODE, mphc_total_pop, mphc_median_hh_size, mphc_mean_hh_size, dhs_median_hh_size, dhs_mean_hh_size, observed_hh_count,dhs_hh_count, mphc_hh_count, ict_hh_count, ihs_hh_count, - naca_hh_count, zomba_hh_count, malemia_hh_count, zomba_pop, female_count, male_count, starts_with("age_")) + naca_hh_count, zomba_hh_count, malemia_hh_count, + # zomba_pop, ### excluding here as commented out in processed code above so not created by default + female_count, male_count, starts_with("age_")) #Write to file -write.csv(combined_data, paste0(output_path, "summarized_survey_data.csv"), row.names = F) +write.csv(combined_data, file.path(output_path, "summarized_survey_data.csv"), row.names = F) #join combined data to EA shapefile and export #Join to ea data combined_data <- combined_data %>% - mutate(EA_CODE = as.character(EA_CODE)) #convert EA code to interger + mutate(EA_CODE = as.character(EA_CODE)) #convert EA code to integer #select hh size hh_size <- combined_data %>% @@ -873,7 +980,7 @@ hh_ea <- hh_ea %>% select(EA_CODE, mphc_total_pop, mphc_median_hh_size, mphc_mean_hh_size) #write to file -st_write(hh_ea, paste(output_path, "hh_size_data.gpkg"), append = T) +st_write(hh_ea, file.path(output_path, "hh_size_data.gpkg"), append = T) #################### END OF SCRIPT ######################################### diff --git a/01_Raster_Mosaicking_Buildings_2018.R b/01_Raster_Mosaicking_Buildings_2018.R index 0fc481e..47f2828 100644 --- a/01_Raster_Mosaicking_Buildings_2018.R +++ b/01_Raster_Mosaicking_Buildings_2018.R @@ -1,26 +1,34 @@ -#Script to mosaic rasters using neighboring countries +# Script to mosaic rasters using neighboring countries library(terra) library(sf) library(tictoc) +source("utils.R") + # Specify data path -drive_path <- "//Working/MALAWI/Ortis/" -base_path <- paste0(drive_path, "Input_Data/") ## Base path where the folders are located -shp_path <- paste0(drive_path, "Input_Data/Shapefiles/") ## Shapefile path -result_path <- paste0(drive_path, "Input_Data/Mosaic_Buildings_2018/") # Result path -building_path <- paste0(drive_path, "Input_Data/Malawi_Covs/2018_Buildings/") +drive_path <- "./data" +base_path <- paste0(drive_path) ## Base path where the folders are located +shp_path <- file.path(drive_path, "Shapefiles") ## Shapefile path +result_path <- file.path(drive_path, "Mosaic_Buildings_2018") # Result path +building_path <- file.path(drive_path, "Malawi_Covs", "2018_Buildings") #Load data -boundary <- st_read(paste0(shp_path, "Country_Shapefile_Buffer_10km.shp")) -r1 <- rast(paste0(building_path, "mwi_buildings_count_2018_glv2_5_t0_5_C_100m_v1.tif")) +boundary_data_filename <- "Country_Shapefile_Buffer_10km.shp" +if(file.exists(file.path(shp_path, boundary_data_filename))) { + boundary <- st_read(file.path(shp_path, boundary_data_filename)) +} else { + boundary <- generate_buffered_country_boundary(shape_path = shp_path, file_name = boundary_data_filename, buffer = 10E3) +} + +r1 <- rast(file.path(building_path, "mwi_buildings_count_2018_glv2_5_t0_5_C_100m_v1.tif")) #Reproject boundary to r1 boundary <- st_transform(boundary, crs = st_crs(r1)) # Define folder names -folders <- c("Malawi_Covs/2018_Buildings","Mozambique_Covs/2018_Buildings", - "Tanzania_Covs/2018_Buildings", "Zambia_Covs/2018_Buildings") +folders <- c("Malawi_Covs/2018_Buildings", "Tanzania_Covs/2018_Buildings", + "Mozambique_Covs/2018_Buildings", "Zambia_Covs/2018_Buildings") # Initialize a list to store raster file names @@ -65,6 +73,11 @@ process_raster <- function(raster_name) { # Save the masked raster to a file with a name based on the original raster file name output_name <- paste0("MOS_MLW", raster_name) + + if (!file.exists(result_path)){ + dir.create(file.path(result_path)) + } + writeRaster(masked_raster, file.path(result_path, output_name), overwrite = TRUE) # Display a message after saving the raster diff --git a/01_Raster_Mosaicking_Buildings_2024.R b/01_Raster_Mosaicking_Buildings_2024.R index 45140c7..36a07ff 100644 --- a/01_Raster_Mosaicking_Buildings_2024.R +++ b/01_Raster_Mosaicking_Buildings_2024.R @@ -2,16 +2,23 @@ library(terra) library(sf) library(tictoc) +source("utils.R") + # Specify data path -drive_path <- "//Working/MALAWI/Ortis/" -base_path <- paste0(drive_path, "Input_Data/") ## Base path where the folders are located -shp_path <- paste0(drive_path, "Input_Data/Shapefiles/") ## Shapefile path -result_path <- paste0(drive_path, "Input_Data/Mosaic_Buildings_2024/") # Result path -building_path <- paste0(drive_path, "Input_Data/Malawi_Covs/2024_Buildings/") +drive_path <- "./data/" +base_path <- file.path(drive_path) ## Base path where the folders are located +shp_path <- file.path(drive_path, "Shapefiles") ## Shapefile path +result_path <- file.path(drive_path, "Mosaic_Buildings_2024") # Result path +building_path <- file.path(drive_path, "Malawi_Covs", "2024_Buildings") #Load data -boundary <- st_read(paste0(shp_path, "Country_Shapefile_Buffer_10km.shp")) -r1 <- rast(paste0(building_path, "mwi_buildings_count_2023_glv2_5_t0_5_C_100m_v1.tif")) +boundary_data_filename <- "Country_Shapefile_Buffer_10km.shp" +if(file.exists(file.path(shp_path, boundary_data_filename))) { + boundary <- st_read(file.path(shp_path, boundary_data_filename)) +} else { + boundary <- generate_buffered_country_boundary(shape_path = shp_path, file_name = boundary_data_filename, buffer = 10E3) +} +r1 <- rast(file.path(building_path, "mwi_buildings_count_2023_glv2_5_t0_5_C_100m_v1.tif")) #Reproject boundary to r1 boundary <- st_transform(boundary, crs = st_crs(r1)) @@ -63,6 +70,11 @@ process_raster <- function(raster_name) { # Save the masked raster to a file with a name based on the original raster file name output_name <- paste0("MOS_MLW", raster_name) + + if (!file.exists(result_path)){ + dir.create(file.path(result_path)) + } + writeRaster(masked_raster, file.path(result_path, output_name), overwrite = TRUE) # Display a message after saving the raster diff --git a/01_Raster_Mosaicking_Workflow_2018.R b/01_Raster_Mosaicking_Workflow_2018.R index cf0b1b9..9225eb9 100644 --- a/01_Raster_Mosaicking_Workflow_2018.R +++ b/01_Raster_Mosaicking_Workflow_2018.R @@ -2,16 +2,24 @@ library(terra) library(sf) library(tictoc) +source("utils.R") + # Specify data path -drive_path <- "//Working/MALAWI/Ortis/" -base_path <- paste0(drive_path, "Input_Data/") ## Base path where the folders are located -shp_path <- paste0(drive_path, "Input_Data/Shapefiles/") ## Shapefile path -result_path <- paste0(drive_path, "Input_Data/Mosaic_Covariates_2018/") # Result path -building_path <- paste0(drive_path, "Input_Data/Malawi_Covs/2024_Buildings/") +drive_path <- "./data/" +base_path <- file.path(drive_path) ## Base path where the folders are located +shp_path <- file.path(drive_path, "Shapefiles") ## Shapefile path +result_path <- file.path(drive_path, "Mosaic_Covariates_2018") # Result path +building_path <- file.path(drive_path, "Malawi_Covs", "2024_Buildings") #Load data -boundary <- st_read(paste0(shp_path, "Country_Shapefile_Buffer_10km.shp")) -r1 <- rast(paste0(building_path, "mwi_buildings_count_2023_glv2_5_t0_5_C_100m_v1.tif")) +boundary_data_filename <- "Country_Shapefile_Buffer_10km.shp" +if(file.exists(file.path(shp_path, boundary_data_filename))) { + boundary <- st_read(file.path(shp_path, boundary_data_filename)) +} else { + boundary <- generate_buffered_country_boundary(shape_path = shp_path, file_name = boundary_data_filename, buffer = 10E3) +} + +r1 <- rast(file.path(building_path, "mwi_buildings_count_2023_glv2_5_t0_5_C_100m_v1.tif")) #Reproject boundary to r1 boundary <- st_transform(boundary, crs = st_crs(r1)) @@ -74,7 +82,12 @@ process_raster <- function(raster_name) { # Save the mosaicked raster to a file with a name based on the original raster file name output_name <- paste0("MOS_MLW", raster_name) - writeRaster(masked_raster, paste0(result_path, output_name), overwrite = TRUE) + + if (!file.exists(result_path)){ + dir.create(file.path(result_path)) + } + + writeRaster(masked_raster, file.path(result_path, output_name), overwrite = TRUE) message("Saved ", output_name) diff --git a/01_Raster_Mosaicking_Workflow_2024.R b/01_Raster_Mosaicking_Workflow_2024.R index 63c957b..6576b85 100644 --- a/01_Raster_Mosaicking_Workflow_2024.R +++ b/01_Raster_Mosaicking_Workflow_2024.R @@ -2,16 +2,24 @@ library(terra) library(sf) library(tictoc) +source("utils.R") + # Specify data path -drive_path <- "//Working/MALAWI/Ortis/" -base_path <- paste0(drive_path, "Input_Data/") ## Base path where the folders are located -shp_path <- paste0(drive_path, "Input_Data/Shapefiles/") ## Shapefile path -result_path <- paste0(drive_path, "Input_Data/Mosaic_Covariates_2024/") # Result path -building_path <- paste0(drive_path, "Input_Data/Malawi_Covs/2024_Buildings/") +drive_path <- "./data/" +base_path <- file.path(drive_path) ## Base path where the folders are located +shp_path <- file.path(drive_path, "Shapefiles") ## Shapefile path +result_path <- file.path(drive_path, "Mosaic_Covariates_2024") # Result path +building_path <- file.path(drive_path, "Malawi_Covs", "2024_Buildings/") #Load data -boundary <- st_read(paste0(shp_path, "Country_Shapefile_Buffer_10km.shp")) -r1 <- rast(paste0(building_path, "mwi_buildings_count_2023_glv2_5_t0_5_C_100m_v1.tif")) +boundary_data_filename <- "Country_Shapefile_Buffer_10km.shp" +if(file.exists(file.path(shp_path, boundary_data_filename))) { + boundary <- st_read(file.path(shp_path, boundary_data_filename)) +} else { + boundary <- generate_buffered_country_boundary(shape_path = shp_path, file_name = boundary_data_filename, buffer = 10E3) +} + +r1 <- rast(file.path(building_path, "mwi_buildings_count_2023_glv2_5_t0_5_C_100m_v1.tif")) #Reproject boundary to r1 boundary <- st_transform(boundary, crs = st_crs(r1)) @@ -74,7 +82,12 @@ process_raster <- function(raster_name) { # Save the mosaicked raster to a file with a name based on the original raster file name output_name <- paste0("MOS_MLW", raster_name) - writeRaster(masked_raster, paste0(result_path, output_name), overwrite = TRUE) + + if (!file.exists(result_path)){ + dir.create(file.path(result_path)) + } + + writeRaster(masked_raster, file.path(result_path, output_name), overwrite = TRUE) message("Saved ", output_name) diff --git a/02_Covariates_Extraction.R b/02_Covariates_Extraction.R index abcfc97..5fae453 100644 --- a/02_Covariates_Extraction.R +++ b/02_Covariates_Extraction.R @@ -9,9 +9,9 @@ library(terra) library(exactextractr) #Specify Drive Path -drive_path <- "//Working/MALAWI/Ortis/" +drive_path <- "./data/" input_path <- paste0(drive_path, "Output_Data/") -shapefile_path <- paste0(drive_path, "Input_Data/Shapefiles/") +shapefile_path <- paste0(drive_path, "Shapefiles/") covs_path_2018 <- paste0(drive_path, "Input_Data/Mosaic_Covariates_2018/") covs_path_2024 <- paste0(drive_path, "Input_Data/Mosaic_Covariates_2024/") bcount_path_2018 <- paste0(drive_path, "Input_Data/Mosaic_Buildings_2018/") @@ -20,7 +20,7 @@ output_path <- paste0(drive_path, "Output_Data/") # Load dataset ------------------------------------------------------------ -ea <- st_read(file.path(shapefile_path, "EA_Shapefile.shp")) +ea <- st_read(file.path(shapefile_path, "2018_MPHC_EAs_Final_for_Use.shp")) # replaces "EA_Shapefile.shp" pop_data <- read.csv(file.path (input_path, "summarized_survey_data.csv")) r1 <- rast(file.path(bcount_path_2024, "MOS_MLW_buildings_count_2023_glv2_5_t0_5_C_100m_v1.tif")) @@ -61,14 +61,18 @@ bcount_2024_extract <- bcount_2024_extract |> microsoft_PIB = sum.buildings_count_PIB_ms_100m_v1_1) #Extract non residential bcount -non_res <- rast(paste0(input_path, "non_res_raster.tif")) - -non_res_extract <- exactextractr::exact_extract(non_res, ea, fun = 'sum') - -#convert to tibille -non_res_extract <- non_res_extract |> - as_tibble() |> - rename(non_res_bcount = value) +# Check if non_res_raster.tif exists before loading +non_res_path <- paste0(input_path, "non_res_raster.tif") +if (file.exists(non_res_path)) { + non_res <- rast(non_res_path) + non_res_extract <- exactextractr::exact_extract(non_res, ea, fun = 'sum') + non_res_extract <- non_res_extract |> + as_tibble() |> + rename(non_res_bcount = value) +} else { + non_res_extract <- NULL + message("non_res_raster.tif not found, skipping non-res extraction.") +} ##################################################################################### @@ -83,9 +87,14 @@ non_res_extract <- non_res_extract |> raster_list <-list.files(path=covs_path_2024, pattern= ".tif$", all.files=TRUE, full.names=FALSE) raster_list -#Stack all covariates +#Stack all unique covariates raster_2024_covariates <- rast(paste0(covs_path_2024, c(raster_list))) +names(raster_2024_covariates) <- sources(raster_2024_covariates) %>% + lapply(str_split_i, "/", -1) %>% + lapply(str_split_i, ".tif", 1) + + #Extract rasters using their mean values tic() @@ -97,7 +106,7 @@ toc() var_names <- names(raster_2024_extract) #Change names -colnames(raster_2024_extract) <- c(paste0('x', 1:64)) +colnames(raster_2024_extract) <- c(paste0('x', 1:length(raster_2024_extract))) #Extract names of raster var_names2<- names(raster_2024_extract) @@ -127,9 +136,15 @@ lat_long <- lat_long %>% #Cbind raster_extract to ea -ea_2024 <- ea %>% - cbind(bcount_2024_extract, non_res_extract, raster_2024_extract, lat_long) |> - as_tibble() +if (file.exists(non_res_path)) { + ea_2024 <- ea %>% + cbind(bcount_2024_extract, non_res_extract, raster_2024_extract, lat_long) |> + as_tibble() +} else { + ea_2024 <- ea %>% + cbind(bcount_2024_extract, raster_2024_extract, lat_long) |> + as_tibble() +} #convert pop data to character pop_data <- pop_data |> @@ -173,14 +188,22 @@ rename(google_v2_5 = sum.buildings_count_2018_glv2_5_t0_5_C_100m_v1, microsoft_BCB = sum.buildings_count_BCB_ms_100m_v1_1) #Extract non residential bcount -non_res <- rast(paste0(input_path, "non_res_raster.tif")) - -non_res_extract <- exactextractr::exact_extract(non_res, ea, fun = 'sum') +# Check if non_res_raster.tif exists before loading +non_res_path <- paste0(input_path, "non_res_raster.tif") +if (file.exists(non_res_path)) { + non_res <- rast(paste0(input_path, "non_res_raster.tif")) + + non_res_extract <- exactextractr::exact_extract(non_res, ea, fun = 'sum') + + #convert to tibille + non_res_extract <- non_res_extract |> + as_tibble() |> + rename(non_res_bcount = value) +} else { + non_res_extract <- NULL + message("non_res_raster.tif not found, skipping non-res extraction.") +} -#convert to tibille -non_res_extract <- non_res_extract |> - as_tibble() |> - rename(non_res_bcount = value) # Extract 2018 covariates ------------------------------------------------- @@ -192,6 +215,10 @@ raster_list #Stack all covariates raster_2018_covariates <- rast(paste0(covs_path_2018, c(raster_list))) +# Remove layers with duplicate names (keep only the first occurrence) +unique_layers_2018 <- !duplicated(names(raster_2018_covariates)) +raster_2018_covariates <- raster_2018_covariates[[unique_layers_2018]] + #Extract rasters using their mean values tic() @@ -203,7 +230,7 @@ toc() var_names <- names(raster_2018_extract) #Change names -colnames(raster_2018_extract) <- c(paste0('x', 1:64)) +colnames(raster_2018_extract) <- c(paste0('x', 1:length(raster_2018_extract))) #Extract names of raster var_names2<- names(raster_2018_extract) @@ -233,9 +260,16 @@ lat_long <- lat_long %>% #Cbind raster_extract to ea -ea_2018 <- ea %>% - cbind(bcount_2018_extract, non_res_extract, raster_2018_extract, lat_long) |> - as_tibble() +if (file.exists(non_res_path)) { + ea_2018 <- ea %>% + cbind(bcount_2018_extract, non_res_extract, raster_2018_extract, lat_long) |> + as_tibble() +} else { + ea_2018 <- ea %>% + cbind(bcount_2018_extract, raster_2018_extract, lat_long) |> + as_tibble() + +} #convert pop data to character pop_data <- pop_data |> diff --git a/03_HH_Model_Workflow_2024c.R b/03_HH_Model_Workflow_2024c.R index e90df29..48662a1 100644 --- a/03_HH_Model_Workflow_2024c.R +++ b/03_HH_Model_Workflow_2024c.R @@ -9,6 +9,7 @@ library(terra) library(kableExtra) library(inlabru) library(feather) +library(glmnet) library(tidyverse) set.seed(1234) #set seed for reproducibility @@ -17,7 +18,7 @@ options(scipen = 999) # turn off scientific notation for all variables #options(digits = 3) #Specify Drive Path -drive_path <- "//Working/MALAWI/Ortis/" +drive_path <- "./data/" input_path <- paste0(drive_path, "Output_Data/") shapefile_path <- paste0(drive_path, "Input_Data/Shapefiles/") output_path <- paste0(drive_path, "Output_Data/") @@ -25,7 +26,7 @@ output_path1 <- paste0(drive_path, "Output_Data/Pop_Rasters/") #Load data pop_data <- read.csv(paste0(input_path, "Malawi_2024_data.csv")) -shapefile <- st_read(paste0(shapefile_path, "2018_MPHC_EAs_Final_for_Use_Corrected.shp")) +shapefile <- st_read(paste0(shapefile_path, "2018_MPHC_EAs_Final_for_Use.shp")) #create unique id for each district pop_data <- pop_data %>% @@ -280,9 +281,9 @@ print(final_formula) #function to drop non-significant variables # Start with full model -current_formula <- as.formula("hh_density ~ x13 + x32 + x36 + x38 + x39 + x40 + - x41 + x44 + x45 + x47 + x49 + x51 + x55 + x56 + x61 + x63 + - x64") +current_formula <- as.formula("hh_density ~ x19 + x26 + x36 + x37 + x39 + x40 + + x43 + x46 + x48 + x50 + x52 + x54 + x55 + x56 + x57 + x60 + + x61 + x62") # Loop to drop non-significant variables repeat { @@ -327,8 +328,8 @@ covs_selection1 <- covs_selection %>% #Lasso Regression fit1_lasso <- train( - hh_density ~ x13 + x32 + x36 + x38 + x39 + x41 + x44 + x45 + - x47 + x49 + x55 + x56 + x61 + x63 + x64, + hh_density ~ x19 + x26 + x36 + x40 + x43 + x46 + x48 + x54 + + x55 + x57 + x60 + x61 + x62, data = covs_selection1, method = "glmnet", metric = "RMSE", # Choose from RMSE, RSquared, AIC, BIC, ...others? diff --git a/03_Pop_Model_Workflow_2018.R b/03_Pop_Model_Workflow_2018.R index f7c9796..e9aa2a7 100644 --- a/03_Pop_Model_Workflow_2018.R +++ b/03_Pop_Model_Workflow_2018.R @@ -18,9 +18,9 @@ options(scipen = 999) # turn off scientific notation for all variables #options(digits = 3) #Specify Drive Path -drive_path <- "//Working/MALAWI/Ortis/" +drive_path <- "./data/" input_path <- paste0(drive_path, "Output_Data/") -shapefile_path <- paste0(drive_path, "Input_Data/Shapefiles/") +shapefile_path <- paste0(drive_path, "Shapefiles/") output_path <- paste0(drive_path, "Output_Data/") output_path1 <- paste0(drive_path, "Output_Data/Pop_Rasters/") diff --git a/04_Covs_Stack_Raster_cropping.R b/04_Covs_Stack_Raster_cropping.R index 727b45b..ebdb9af 100644 --- a/04_Covs_Stack_Raster_cropping.R +++ b/04_Covs_Stack_Raster_cropping.R @@ -6,10 +6,10 @@ library(feather) library(sf) #Specify Drive Path -drive_path <- "//Working/MALAWI/Ortis/" +drive_path <- "./data/" covs_path_2024 <- paste0(drive_path, "Input_Data/Mosaic_Covariates_2024/") output_path <- paste0(drive_path, "Output_Data/") -shapefile_path <- paste0(drive_path, "Input_Data/Shapefiles/") +shapefile_path <- paste0(drive_path, "Shapefiles/") bcount_path_2024 <- paste0(drive_path, "Input_Data/Mosaic_Buildings_2024/") @@ -143,7 +143,7 @@ prediction_covs <- prediction_covs |> #Read EA shapefiles and join to data -ea <- st_read(file.path(shapefile_path, "EA_Shapefile.shp")) +ea <- st_read(file.path(shapefile_path, "2018_MPHC_EAs_Final_for_Use.shp")) # replaces "EA_Shapefile.shp" #create unique id for each district district <- ea |> diff --git a/04_Rasterize.R b/04_Rasterize.R index 5ad31c4..0384057 100644 --- a/04_Rasterize.R +++ b/04_Rasterize.R @@ -8,15 +8,14 @@ library(raster) #Specify Drive Path -drive_path <- "//Working/MALAWI/Ortis/" +drive_path <- "./data/" output_path <- paste0(drive_path, "Output_Data/") -shapefile_path <- paste0(drive_path, "Input_Data/Shapefiles/") +shapefile_path <- paste0(drive_path, "Shapefiles/") bcount_path_2024 <- paste0(drive_path, "Input_Data/Mosaic_Buildings_2024/") #Load datasets -ea <- st_read(file.path(shapefile_path, "EA_Shapefile.shp")) +ea <- st_read(file.path(shapefile_path, "2018_MPHC_EAs_Final_for_Use.shp")) # replaces "EA_Shapefile.shp" bcount <- rast(file.path(bcount_path_2024, "MOS_MLW_buildings_count_2023_glv2_5_t0_5_C_100m_v1.tif")) -country <- st_read(file.path(shapefile_path, "Country_Shapefile.shp")) hh_size <- read.csv(paste0(output_path, "summarized_survey_data.csv")) mphc_structures_2018 <- st_read(paste0(output_path, "mphc_structures_points.gpkg")) mphc_2018_sf <- st_read(paste0(output_path, "mphc_2018_sf_ea.gpkg")) @@ -45,11 +44,36 @@ hh_size <- hh_size |> hh_ea <-full_join(ea, hh_size, by = "EA_CODE") # Rasterize Country ------------------------------------------------------ - -country <- st_transform(country, crs = st_crs(bcount)) - -country_raster <- rasterize(country, bcount, field = "Country_ID") -plot(country_raster) +country_data_filename <- "Country_Shapefile.shp" +if(file.exists(file.path(shapefile_path, country_data_filename))) { + country <- st_read(file.path(shapefile_path, country_data_filename)) +} else { + country <- generate_buffered_country_boundary(shape_path = shapefile_path, + file_name = country_data_filename, + buffer = 0) +} + +# Handle both outputs from generate_buffered_country_boundary(): sf or bare sfc geometry. +country <- if (inherits(country, "sf")) { + country +} else { + st_as_sf(country) +} + +# If geometry came back without CRS, assume EA CRS because country was derived from EA union. +if (is.na(st_crs(country))) { + country <- st_set_crs(country, st_crs(ea)) +} + +country <- country %>% + st_transform(crs = st_crs(bcount)) %>% + st_make_valid() %>% + mutate(Country_ID = 1L) + +# Rasterize from terra vector for consistent behavior. +country_raster <- terra::rasterize(terra::vect(country), bcount, field = "Country_ID", touches = TRUE) +plot(country_raster, col = "#e63946", plg = list(title = "country_id")) +plot(terra::as.polygons(country_raster, dissolve = TRUE), add = TRUE, border = "black", lwd = 0.6) #stack rasters stack_raster <- c(bcount, country_raster) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4d009d2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Office for National Statistics + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index e43313e..b1cdfab 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,42 @@ -# Malawi_Project -# 📌 Malawi_Project Workflow +# WorldPop-Malawi-fork (ons-compatability-updates branch) -This repository contains a structured workflow for **geospatial data processing**, **raster preparation**, **covariate extraction** and **modelling workflow** for population modeling in Malawi. -The scripts are organized in sequential stages to ensure a reproducible and streamlined processing pipeline. +## Project Overview ---- +This project provides scripts and workflows for processing, analyzing, and modeling population and building data for Malawi, following the WorldPop methodology and adapted for ONS compatibility. -## 📂 Repository Structure +## Branch Information -| File | Description | -|------|-----------| -| `00_Data_Processing2.R` | Initial preprocessing of household survey or enumeration data. | -| `01_Raster_Mosaicking_Buildings_2018.R` | Mosaicking of 2018 Google footprint rasters. | -| `01_Raster_Mosaicking_Buildings_2024.R` | Mosaicking of 2024 updated building footprint data. | -| `01_Raster_Mosaicking_Workflow_2018.R` | Full workflow script for 2018 covariates raster mosaicking automation. | -| `01_Raster_Mosaicking_Workflow_2024.R` | Automated workflow for mosaicking 2024 covariates raster data. | -| `02_Covariates_Extraction.R` | Extraction of geospatial covariates for modelling at the EA. | -| `04_Rasterize.R` | Converts vector geospatial layers into raster format for analysis. | -| `04_Covs_Stack_Raster_cropping.R` | Creating the prediction grid. | -| `README.md` | Overview and usage instructions (this file). | +This is the `ons-compatability-updates` branch, which includes updates for compatibility with ONS workflows and standards. ---- +## Dependencies -## 🎯 Objective +To install all required packages, run this in your R console: -The main goal of this project is to **model household count** and **population** for census preparation in Malawi +``` r +install.packages(c("tidyverse", "sf", "tictoc", "terra", "exactextractr", "haven", "nngeo", "INLA", "gstat", "spdep", "car", "caret", "kableExtra", "inlabru", "feather", "raster", "glmnet")) +``` ---- +## Data Pre-processing -## 🔄 Processing Flow +Before running the main scripts, data pre-processing steps are required. Please refer to the [Pre-processing Steps section of the project wiki](https://github.com/datasciencecampus/WorldPop-Malawi-fork/wiki/Pre-processing-Steps) for detailed instructions. -1. **Data Cleaning & Setup (`00_*.R`)** -2. **Raster Mosaicking (`01_*.R`)** - - Process and harmonize building footprints -3. **Covariate Preparation (`02_*.R`)** -4. **Rasterization of Vector Inputs (`04_Rasterize.R`)** -5. **Covariate Raster Stacking & Cropping (`04_Covs_*.R`)** +Run the following scripts in order for a typical workflow: ---- +1. `01_Raster_Mosaicking_Buildings_2018.R` - successfully run +2. `01_Raster_Mosaicking_Buildings_2024.R` - successfully run +3. `01_Raster_Mosaicking_Workflow_2018.R` - successfully run +4. `01_Raster_Mosaicking_Workflow_2024.R` - successfully run +5. `00_Data_Processing.R` - successfully run +6. `00_Data_Processing2.R` - successfully run +7. `04_Rasterize.R` - mostly not used except for "# Rasterize Country" (line 47) +8. `02_Covariates_Extraction.R` - successfully run - with caveat modified to work without data created in `04_Rasterize.R` -## 🛠️ Requirements +## Modelling scripts -Make sure the following R packages are installed: +In progress - see [Model code review of the project wiki](https://github.com/datasciencecampus/WorldPop-Malawi-fork/wiki/Model-code-review) -```r -install.packages(c("tidyverse", "sf", "terra", "raster", "exactextractr")) +The important script in this section is `03_HH_Model_Workflow_2024.R` + +## Additional Resources + +- [Full Project Wiki](https://github.com/datasciencecampus/WorldPop-Malawi-fork/wiki) diff --git a/data_merge_zomba.R b/data_merge_zomba.R new file mode 100644 index 0000000..ede6bb6 --- /dev/null +++ b/data_merge_zomba.R @@ -0,0 +1,96 @@ +library(tidyverse) + +#Loading data zomba_csv +Chikowi <- read_csv("Chikowi.csv") +glimpse(Chikowi) +chimbalanga <- read_csv("Chimbalanga.csv") +glimpse(chimbalanga) +idana <- read_csv("Idana.csv") +glimpse(idana) +kumtumanji <- read_csv("Kumtumanji.csv") +glimpse(kumtumanji) +Malemia <- read_csv("Malemia.csv") +glimpse(Malemia) +Mbiza <- read_csv("Mbiza.csv") +glimpse(Mbiza) +Mkumbira <- read_csv("Mkumbira.csv") +glimpse(Mkumbira) +Mlumbe <- read_csv("Mlumbe.csv") +glimpse(Mlumbe) +Mwambo <- read_csv("Mwambo.csv") +glimpse(Mwambo) +Mwembere <- read_csv("Mwembere.csv") +glimpse(Mwembere) +Ngwelero <- read_csv("Ngwelero.csv") +glimpse(Ngwelero) +Nkagula <- read_csv("Nkagula.csv") +glimpse(Nkagula) +Nkapita <- read_csv("Nkapita.csv") +glimpse(Nkapita) +Ntholowa <- read_csv("Ntholowa.csv") +glimpse(Ntholowa) + +#loading Malemia hh data +Malemia_hh <- read_csv("malemia_hh_without_IDs.csv") + +#standardize column labels +standardise_names <- function(df) { + df %>% + rename_with(~ "household_number", + .cols = any_of(c("HOUSEHOLD NUMBER", "household_name"))) +} + + +Chikowi <- standardise_names(Chikowi) +chimbalanga <- standardise_names(chimbalanga) +idana <- standardise_names(idana) +kumtumanji <- standardise_names(kumtumanji) +Malemia <- standardise_names(Malemia) +Mbiza <- standardise_names(Mbiza) +Mkumbira <- standardise_names(Mkumbira) +Mlumbe <- standardise_names(Mlumbe) +Mwambo <- standardise_names(Mwambo) +Mwembere <- standardise_names(Mwembere) +Ngwelero <- standardise_names(Ngwelero) +Nkagula <- standardise_names(Nkagula) +Nkapita <- standardise_names(Nkapita) +Ntholowa <- standardise_names(Ntholowa) + +#validate +colnames(Chikowi) + +#Merge files +zomba_rbind_data <- bind_rows( + Chikowi, + chimbalanga, + idana, + kumtumanji, + Malemia, + Mbiza, + Mkumbira, + Mwambo, + Mlumbe, + Mwembere, + Ngwelero, + Nkagula, + Nkapita, + Ntholowa +) + +glimpse(zomba_rbind_data) + +#remove the fully empty rows +zomba_rbind_data <- zomba_rbind_data %>% + filter(!if_all(everything(), is.na)) + +#to confirm all TAs are included +count(zomba_rbind_data, traditional_authority_name) + +#to write it as a CSV + +write.csv( + zomba_rbind_data, + "zomba_households_merged.csv", + row.names = FALSE +) + diff --git a/load_required_libraries.R b/load_required_libraries.R new file mode 100644 index 0000000..c687ddd --- /dev/null +++ b/load_required_libraries.R @@ -0,0 +1,42 @@ +load_library <- function(library_name) { + #' Check if named library installed, if so load, if not install and load + #' + #' @param library_name (character). The name of the library to be installed/loaded. + #' + if (library_name %in% rownames(installed.packages()) == FALSE) { + print(paste0("The required library '", library_name, "' is not installed, installing now.")) + install.packages(library_name, dependencies = TRUE) + library(library_name, character.only = TRUE) + } else { + library(library_name, character.only = TRUE) + } +} + +load_libraries <- function(library_names) { + #' Apply the load_library function across a vector of library names. + #' + #' @param library_names (vector). A vector of libraries to be loaded (or installed). + #' + sapply(library_names, load_library) +} + +# Add any required packages to this list +required_libraries <- c( + "sf", # package for handling spatial data + "tidyverse", # tidyverse + "haven", # package for import foreign statistical formats + "terra", # package for spatial data analysis + "tictoc", # package for timing R Scripts + "exactextractr", # zonal statistics of polygons + "gstat", # Spatial and Spatio-Temporal Geostatistical Modelling, Prediction and Simulation + "spdep", # spatial dependence and weights + "car", # Companion to Applied Regression + "caret", # Classification And REgression Training + "kableExtra", # for html tables + "inlabru", # package for Bayesian spatial modelling + "feather", # reading and writing feather files + "nngeo" # nearest neighbour in geospatial +) + +# Execute code to load (and install) libraries +load_libraries(required_libraries) diff --git a/src_covariates/covariate_download.log b/src_covariates/covariate_download.log new file mode 100644 index 0000000..0403a7b --- /dev/null +++ b/src_covariates/covariate_download.log @@ -0,0 +1,243 @@ +2026-01-27 12:49:36,824 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_count_BCB_gl_100m_v1_1.tif +2026-01-27 12:49:41,029 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_count_BCB_gl_100m_v1_1.tif +2026-01-27 12:49:42,821 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_count_BCB_gl_100m_v1_1.tif +2026-01-27 12:49:44,044 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_count_BCB_gl_100m_v1_1.tif +2026-01-27 12:49:44,923 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_count_BCB_ms_100m_v1_1.tif +2026-01-27 12:49:50,178 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_count_BCB_ms_100m_v1_1.tif +2026-01-27 12:49:52,577 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_count_BCB_ms_100m_v1_1.tif +2026-01-27 12:49:54,086 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_count_BCB_ms_100m_v1_1.tif +2026-01-27 12:49:56,312 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_cv_area_BCB_gl_100m_v1_1.tif +2026-01-27 12:50:05,702 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_cv_area_BCB_gl_100m_v1_1.tif +2026-01-27 12:50:09,084 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_cv_area_BCB_gl_100m_v1_1.tif +2026-01-27 12:50:11,176 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_cv_area_BCB_gl_100m_v1_1.tif +2026-01-27 12:50:13,187 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_cv_area_BCB_ms_100m_v1_1.tif +2026-01-27 12:50:15,354 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_cv_area_BCB_ms_100m_v1_1.tif +2026-01-27 12:50:18,276 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_cv_area_BCB_ms_100m_v1_1.tif +2026-01-27 12:50:19,767 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_cv_area_BCB_ms_100m_v1_1.tif +2026-01-27 12:50:21,800 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_cv_area_PIB_gl_100m_v1_1.tif +2026-01-27 12:50:25,073 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_cv_area_PIB_gl_100m_v1_1.tif +2026-01-27 12:50:27,215 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_cv_area_PIB_gl_100m_v1_1.tif +2026-01-27 12:50:29,190 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_cv_area_PIB_gl_100m_v1_1.tif +2026-01-27 12:50:30,425 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_cv_area_PIB_ms_100m_v1_1.tif +2026-01-27 12:50:32,896 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_cv_area_PIB_ms_100m_v1_1.tif +2026-01-27 12:50:35,045 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_cv_area_PIB_ms_100m_v1_1.tif +2026-01-27 12:50:37,464 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_cv_area_PIB_ms_100m_v1_1.tif +2026-01-27 12:50:39,519 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_cv_length_BCB_gl_100m_v1_1.tif +2026-01-27 12:50:43,382 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_cv_length_BCB_gl_100m_v1_1.tif +2026-01-27 12:50:45,902 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_cv_length_BCB_gl_100m_v1_1.tif +2026-01-27 12:50:49,507 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_cv_length_BCB_gl_100m_v1_1.tif +2026-01-27 12:50:51,621 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_cv_length_BCB_ms_100m_v1_1.tif +2026-01-27 12:50:53,952 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_cv_length_BCB_ms_100m_v1_1.tif +2026-01-27 12:50:57,903 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_cv_length_BCB_ms_100m_v1_1.tif +2026-01-27 12:51:00,225 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_cv_length_BCB_ms_100m_v1_1.tif +2026-01-27 12:51:01,772 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_cv_length_PIB_gl_100m_v1_1.tif +2026-01-27 12:51:07,826 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_cv_length_PIB_gl_100m_v1_1.tif +2026-01-27 12:51:11,529 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_cv_length_PIB_gl_100m_v1_1.tif +2026-01-27 12:51:15,833 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_cv_length_PIB_gl_100m_v1_1.tif +2026-01-27 12:51:17,467 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_cv_length_PIB_ms_100m_v1_1.tif +2026-01-27 12:51:19,827 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_cv_length_PIB_ms_100m_v1_1.tif +2026-01-27 12:51:24,562 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_cv_length_PIB_ms_100m_v1_1.tif +2026-01-27 12:51:27,393 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_cv_length_PIB_ms_100m_v1_1.tif +2026-01-27 12:51:29,564 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_density_BCB_gl_100m_v1_1.tif +2026-01-27 12:51:35,836 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_density_BCB_gl_100m_v1_1.tif +2026-01-27 12:51:42,686 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_density_BCB_gl_100m_v1_1.tif +2026-01-27 12:51:45,615 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_density_BCB_gl_100m_v1_1.tif +2026-01-27 12:51:50,938 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_density_BCB_ms_100m_v1_1.tif +2026-01-27 12:52:01,288 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_density_BCB_ms_100m_v1_1.tif +2026-01-27 12:52:11,191 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_density_BCB_ms_100m_v1_1.tif +2026-01-27 12:52:12,713 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_density_BCB_ms_100m_v1_1.tif +2026-01-27 12:52:16,519 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_density_PIB_gl_100m_v1_1.tif +2026-01-27 12:52:25,266 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_density_PIB_gl_100m_v1_1.tif +2026-01-27 12:52:33,866 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_density_PIB_gl_100m_v1_1.tif +2026-01-27 12:52:36,570 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_density_PIB_gl_100m_v1_1.tif +2026-01-27 12:52:39,534 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_density_PIB_ms_100m_v1_1.tif +2026-01-27 12:52:50,621 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_density_PIB_ms_100m_v1_1.tif +2026-01-27 12:52:53,304 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_density_PIB_ms_100m_v1_1.tif +2026-01-27 12:52:55,978 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_density_PIB_ms_100m_v1_1.tif +2026-01-27 12:52:57,665 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_mean_area_BCB_gl_100m_v1_1.tif +2026-01-27 12:53:13,347 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_mean_area_BCB_gl_100m_v1_1.tif +2026-01-27 12:53:23,118 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_mean_area_BCB_gl_100m_v1_1.tif +2026-01-27 12:53:25,572 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_mean_area_BCB_gl_100m_v1_1.tif +2026-01-27 12:53:26,611 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_mean_area_BCB_ms_100m_v1_1.tif +2026-01-27 12:53:35,911 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_mean_area_BCB_ms_100m_v1_1.tif +2026-01-27 12:53:43,739 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_mean_area_BCB_ms_100m_v1_1.tif +2026-01-27 12:53:45,484 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_mean_area_BCB_ms_100m_v1_1.tif +2026-01-27 12:53:50,086 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_mean_area_PIB_gl_100m_v1_1.tif +2026-01-27 12:53:55,268 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_mean_area_PIB_gl_100m_v1_1.tif +2026-01-27 12:54:02,839 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_mean_area_PIB_gl_100m_v1_1.tif +2026-01-27 12:54:10,322 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_mean_area_PIB_gl_100m_v1_1.tif +2026-01-27 12:54:12,571 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_mean_area_PIB_ms_100m_v1_1.tif +2026-01-27 12:54:24,947 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_mean_area_PIB_ms_100m_v1_1.tif +2026-01-27 12:54:31,645 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_mean_area_PIB_ms_100m_v1_1.tif +2026-01-27 12:54:35,061 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_mean_area_PIB_ms_100m_v1_1.tif +2026-01-27 12:54:38,337 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_mean_length_BCB_gl_100m_v1_1.tif +2026-01-27 12:54:44,364 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_mean_length_BCB_gl_100m_v1_1.tif +2026-01-27 12:54:47,934 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_mean_length_BCB_gl_100m_v1_1.tif +2026-01-27 12:54:49,819 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_mean_length_BCB_gl_100m_v1_1.tif +2026-01-27 12:54:52,262 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_mean_length_BCB_ms_100m_v1_1.tif +2026-01-27 12:54:58,322 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_mean_length_BCB_ms_100m_v1_1.tif +2026-01-27 12:55:03,178 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_mean_length_BCB_ms_100m_v1_1.tif +2026-01-27 12:55:07,951 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_mean_length_BCB_ms_100m_v1_1.tif +2026-01-27 12:55:09,899 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_mean_length_PIB_gl_100m_v1_1.tif +2026-01-27 12:55:18,356 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_mean_length_PIB_gl_100m_v1_1.tif +2026-01-27 12:55:22,281 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_mean_length_PIB_gl_100m_v1_1.tif +2026-01-27 12:55:25,181 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_mean_length_PIB_gl_100m_v1_1.tif +2026-01-27 12:55:26,061 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_mean_length_PIB_ms_100m_v1_1.tif +2026-01-27 12:55:30,642 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_mean_length_PIB_ms_100m_v1_1.tif +2026-01-27 12:55:33,007 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_mean_length_PIB_ms_100m_v1_1.tif +2026-01-27 12:55:35,556 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_mean_length_PIB_ms_100m_v1_1.tif +2026-01-27 12:55:39,424 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_total_area_BCB_gl_100m_v1_1.tif +2026-01-27 12:55:55,873 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_total_area_BCB_gl_100m_v1_1.tif +2026-01-27 12:55:59,967 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_total_area_BCB_gl_100m_v1_1.tif +2026-01-27 12:56:01,895 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_total_area_BCB_gl_100m_v1_1.tif +2026-01-27 12:56:04,321 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_total_area_BCB_ms_100m_v1_1.tif +2026-01-27 12:56:08,051 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_total_area_BCB_ms_100m_v1_1.tif +2026-01-27 12:56:11,058 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_total_area_BCB_ms_100m_v1_1.tif +2026-01-27 12:56:16,092 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_total_area_BCB_ms_100m_v1_1.tif +2026-01-27 12:56:19,577 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_total_area_PIB_gl_100m_v1_1.tif +2026-01-27 12:56:33,222 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_total_area_PIB_gl_100m_v1_1.tif +2026-01-27 12:56:43,696 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_total_area_PIB_gl_100m_v1_1.tif +2026-01-27 12:56:50,471 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_total_area_PIB_gl_100m_v1_1.tif +2026-01-27 12:56:51,740 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_total_area_PIB_ms_100m_v1_1.tif +2026-01-27 12:57:01,108 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_total_area_PIB_ms_100m_v1_1.tif +2026-01-27 12:57:08,326 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_total_area_PIB_ms_100m_v1_1.tif +2026-01-27 12:57:09,892 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_total_area_PIB_ms_100m_v1_1.tif +2026-01-27 12:57:12,237 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_total_length_BCB_gl_100m_v1_1.tif +2026-01-27 12:57:19,687 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_total_length_BCB_gl_100m_v1_1.tif +2026-01-27 12:57:23,135 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_total_length_BCB_gl_100m_v1_1.tif +2026-01-27 12:57:25,807 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_total_length_BCB_gl_100m_v1_1.tif +2026-01-27 12:57:26,966 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_total_length_BCB_ms_100m_v1_1.tif +2026-01-27 12:57:37,916 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_total_length_BCB_ms_100m_v1_1.tif +2026-01-27 12:57:39,899 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_total_length_BCB_ms_100m_v1_1.tif +2026-01-27 12:57:41,682 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_total_length_BCB_ms_100m_v1_1.tif +2026-01-27 12:57:45,193 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_total_length_PIB_gl_100m_v1_1.tif +2026-01-27 12:57:50,818 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_total_length_PIB_gl_100m_v1_1.tif +2026-01-27 12:57:54,677 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_total_length_PIB_gl_100m_v1_1.tif +2026-01-27 12:57:55,961 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_total_length_PIB_gl_100m_v1_1.tif +2026-01-27 12:57:58,382 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_buildings_total_length_PIB_ms_100m_v1_1.tif +2026-01-27 12:58:01,095 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_buildings_total_length_PIB_ms_100m_v1_1.tif +2026-01-27 12:58:05,058 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_buildings_total_length_PIB_ms_100m_v1_1.tif +2026-01-27 12:58:10,246 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_buildings_total_length_PIB_ms_100m_v1_1.tif +2026-01-27 12:58:14,385 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_built_S_dist_2024_GHS_MGW_100m_v1.tif +2026-01-27 12:58:19,985 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_built_S_dist_2018_GHS_MGW_100m_v1.tif +2026-01-27 12:58:37,248 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_built_S_dist_2024_GHS_MGW_100m_v1.tif +2026-01-27 12:59:10,253 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_built_S_dist_2018_GHS_MGW_100m_v1.tif +2026-01-27 12:59:40,257 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_built_S_dist_2024_GHS_MGW_100m_v1.tif +2026-01-27 13:00:00,675 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_built_S_dist_2018_GHS_MGW_100m_v1.tif +2026-01-27 13:00:35,048 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_built_S_dist_2024_GHS_MGW_100m_v1.tif +2026-01-27 13:00:46,245 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_built_S_dist_2018_GHS_MGW_100m_v1.tif +2026-01-27 13:00:48,065 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_built_S_GHS_U_wFGW_100m_v1_2024.tif +2026-01-27 13:00:50,465 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_built_S_GHS_U_wFGW_100m_v1_2018.tif +2026-01-27 13:01:00,486 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_built_S_GHS_U_wFGW_100m_v1_2024.tif +2026-01-27 13:01:12,537 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_built_S_GHS_U_wFGW_100m_v1_2018.tif +2026-01-27 13:01:18,570 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_built_S_GHS_U_wFGW_100m_v1_2024.tif +2026-01-27 13:01:24,153 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_built_S_GHS_U_wFGW_100m_v1_2018.tif +2026-01-27 13:01:27,289 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_built_S_GHS_U_wFGW_100m_v1_2024.tif +2026-01-27 13:01:32,930 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_built_S_GHS_U_wFGW_100m_v1_2018.tif +2026-01-27 13:01:32,930 INFO: Exists: data\covariate_data\Malawi_Covs\mwi_built_S_GHS_U_wFGW_100m_v1_2018.tif +2026-01-27 13:01:36,823 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_built_V_GHS_U_wFGW_100m_v1_2024.tif +2026-01-27 13:01:40,574 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_built_V_GHS_U_wFGW_100m_v1_2018.tif +2026-01-27 13:01:45,890 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_built_V_GHS_U_wFGW_100m_v1_2024.tif +2026-01-27 13:01:53,228 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_built_V_GHS_U_wFGW_100m_v1_2018.tif +2026-01-27 13:02:01,572 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_built_V_GHS_U_wFGW_100m_v1_2024.tif +2026-01-27 13:02:05,863 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_built_V_GHS_U_wFGW_100m_v1_2018.tif +2026-01-27 13:02:11,324 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_built_V_GHS_U_wFGW_100m_v1_2024.tif +2026-01-27 13:02:16,863 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_built_V_GHS_U_wFGW_100m_v1_2018.tif +2026-01-27 13:02:22,910 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_coastline_dst_100m_v1.tif +2026-01-27 13:03:00,314 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_coastline_dst_100m_v1.tif +2026-01-27 13:03:38,155 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_coastline_dst_100m_v1.tif +2026-01-27 13:04:04,769 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_coastline_dst_100m_v1.tif +2026-01-27 13:04:12,954 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_dist_inland_water_100m_esa_2021_v1.tif +2026-01-27 13:04:53,446 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_dist_inland_water_100m_esa_2021_v1.tif +2026-01-27 13:05:19,979 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_dist_inland_water_100m_esa_2021_v1.tif +2026-01-27 13:05:39,720 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_dist_inland_water_100m_esa_2021_v1.tif +2026-01-27 13:05:48,013 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_elevation_merit103_100m_v1.tif +2026-01-27 13:06:16,523 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_elevation_merit103_100m_v1.tif +2026-01-27 13:06:46,734 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_elevation_merit103_100m_v1.tif +2026-01-27 13:07:28,283 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_elevation_merit103_100m_v1.tif +2026-01-27 13:07:31,801 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_esalc_11_dst_2022_100m_v1.tif +2026-01-27 13:08:06,887 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_esalc_11_dst_2022_100m_v1.tif +2026-01-27 13:08:43,465 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_esalc_11_dst_2022_100m_v1.tif +2026-01-27 13:09:07,761 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_esalc_11_dst_2022_100m_v1.tif +2026-01-27 13:09:14,107 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_esalc_130_dst_2022_100m_v1.tif +2026-01-27 13:09:34,972 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_esalc_130_dst_2022_100m_v1.tif +2026-01-27 13:10:04,174 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_esalc_130_dst_2022_100m_v1.tif +2026-01-27 13:10:24,497 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_esalc_130_dst_2022_100m_v1.tif +2026-01-27 13:10:30,004 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_esalc_140_dst_2022_100m_v1.tif +2026-01-27 13:11:03,795 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_esalc_140_dst_2022_100m_v1.tif +2026-01-27 13:11:28,889 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_esalc_140_dst_2022_100m_v1.tif +2026-01-27 13:11:53,139 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_esalc_140_dst_2022_100m_v1.tif +2026-01-27 13:11:57,011 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_esalc_150_dst_2022_100m_v1.tif +2026-01-27 13:12:27,831 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_esalc_150_dst_2022_100m_v1.tif +2026-01-27 13:13:06,681 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_esalc_150_dst_2022_100m_v1.tif +2026-01-27 13:13:55,522 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_esalc_150_dst_2022_100m_v1.tif +2026-01-27 13:14:02,787 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_esalc_160_dst_2022_100m_v1.tif +2026-01-27 13:14:53,788 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_esalc_160_dst_2022_100m_v1.tif +2026-01-27 13:15:28,592 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_esalc_160_dst_2022_100m_v1.tif +2026-01-27 13:16:27,661 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_esalc_160_dst_2022_100m_v1.tif +2026-01-27 13:16:42,126 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_esalc_190_dst_2022_100m_v1.tif +2026-01-27 13:18:19,393 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_esalc_190_dst_2022_100m_v1.tif +2026-01-27 13:20:14,835 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_esalc_190_dst_2022_100m_v1.tif +2026-01-27 13:22:16,640 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_esalc_190_dst_2022_100m_v1.tif +2026-01-27 13:22:48,713 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_esalc_200_dst_2022_100m_v1.tif +2026-01-27 13:27:21,855 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_esalc_200_dst_2022_100m_v1.tif +2026-01-27 13:28:50,316 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_esalc_200_dst_2022_100m_v1.tif +2026-01-27 13:29:58,628 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_esalc_200_dst_2022_100m_v1.tif +2026-01-27 13:30:18,380 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_esalc_210_dst_2022_100m_v1.tif +2026-01-27 13:31:10,284 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_esalc_210_dst_2022_100m_v1.tif +2026-01-27 13:31:48,987 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_esalc_210_dst_2022_100m_v1.tif +2026-01-27 13:32:42,518 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_esalc_210_dst_2022_100m_v1.tif +2026-01-27 13:32:52,344 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_esalc_40_dst_2022_100m_v1.tif +2026-01-27 13:33:27,517 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_esalc_40_dst_2022_100m_v1.tif +2026-01-27 13:34:00,520 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_esalc_40_dst_2022_100m_v1.tif +2026-01-27 13:34:19,810 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_esalc_40_dst_2022_100m_v1.tif +2026-01-27 13:34:30,898 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_highway_dist_osm_2023_100m_v1.tif +2026-01-27 13:35:20,610 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_highway_dist_osm_2023_100m_v1.tif +2026-01-27 13:36:01,330 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_highway_dist_osm_2023_100m_v1.tif +2026-01-27 13:36:34,029 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_highway_dist_osm_2023_100m_v1.tif +2026-01-27 13:36:44,790 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_ppt_2023_yravg_tc_100m_v1.tif +2026-01-27 13:36:52,509 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_ppt_2018_yravg_tc_100m_v1.tif +2026-01-27 13:37:34,912 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_ppt_2023_yravg_tc_100m_v1.tif +2026-01-27 13:38:09,865 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_ppt_2023_yravg_tc_100m_v1.tif +2026-01-27 13:38:46,856 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_ppt_2023_yravg_tc_100m_v1.tif +2026-01-27 13:38:54,665 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_rd_intrs_dist_osm_2023_100m_v1.tif +2026-01-27 13:39:27,964 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_rd_intrs_dist_osm_2023_100m_v1.tif +2026-01-27 13:40:05,626 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_rd_intrs_dist_osm_2023_100m_v1.tif +2026-01-27 13:40:38,807 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_rd_intrs_dist_osm_2023_100m_v1.tif +2026-01-27 13:40:48,058 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_slope_merit103_100m_v1.tif +2026-01-27 13:41:44,110 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_slope_merit103_100m_v1.tif +2026-01-27 13:42:51,653 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_slope_merit103_100m_v1.tif +2026-01-27 13:43:48,065 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_slope_merit103_100m_v1.tif +2026-01-27 13:43:49,690 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_tavg_2023_tlst_100m_v1.tif +2026-01-27 13:43:51,704 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_tavg_2018_tlst_100m_v1.tif +2026-01-27 13:44:02,201 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_tavg_2023_tlst_100m_v1.tif +2026-01-27 13:44:20,973 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_tavg_2023_tlst_100m_v1.tif +2026-01-27 13:44:39,109 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_tavg_2023_tlst_100m_v1.tif +2026-01-27 13:44:42,405 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_viirs_fvf_2023_100m_v1.tif +2026-01-27 13:44:44,367 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_viirs_fvf_2018_100m_v1.tif +2026-01-27 13:44:53,693 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_viirs_fvf_2023_100m_v1.tif +2026-01-27 13:44:57,889 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_viirs_fvf_2018_100m_v1.tif +2026-01-27 13:45:01,575 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_viirs_fvf_2023_100m_v1.tif +2026-01-27 13:45:05,654 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_viirs_fvf_2018_100m_v1.tif +2026-01-27 13:45:13,204 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_viirs_fvf_2023_100m_v1.tif +2026-01-27 13:45:18,196 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_viirs_fvf_2018_100m_v1.tif +2026-01-27 13:45:21,021 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_viirs_nvf_2023_100m_v1.tif +2026-01-27 13:45:22,741 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_viirs_nvf_2018_100m_v1.tif +2026-01-27 13:45:29,462 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_viirs_nvf_2023_100m_v1.tif +2026-01-27 13:45:33,225 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_viirs_nvf_2018_100m_v1.tif +2026-01-27 13:45:36,783 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_viirs_nvf_2023_100m_v1.tif +2026-01-27 13:45:40,731 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_viirs_nvf_2018_100m_v1.tif +2026-01-27 13:45:45,423 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_viirs_nvf_2023_100m_v1.tif +2026-01-27 13:45:48,241 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_viirs_nvf_2018_100m_v1.tif +2026-01-27 13:45:57,472 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_waterbodies_dist_osm_2023_100m_v1.tif +2026-01-27 13:47:59,520 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_waterbodies_dist_osm_2023_100m_v1.tif +2026-01-27 13:50:25,636 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_waterbodies_dist_osm_2023_100m_v1.tif +2026-01-27 13:52:02,712 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_waterbodies_dist_osm_2023_100m_v1.tif +2026-01-27 13:52:27,766 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_WDPA_pre2022_cat0_dist_100m_v1.tif +2026-01-27 13:54:55,663 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_WDPA_pre2022_cat0_dist_100m_v1.tif +2026-01-27 13:58:21,723 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_WDPA_pre2022_cat0_dist_100m_v1.tif +2026-01-27 13:59:45,208 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_WDPA_pre2022_cat0_dist_100m_v1.tif +2026-01-27 14:00:03,667 INFO: Downloaded to data\covariate_data\Malawi_Covs\mwi_WDPA_pre2022_cat1_dist_100m_v1.tif +2026-01-27 14:01:52,446 INFO: Downloaded to data\covariate_data\Tanzania_Covs\tza_WDPA_pre2022_cat1_dist_100m_v1.tif +2026-01-27 14:03:17,146 INFO: Downloaded to data\covariate_data\Mozambique_Covs\moz_WDPA_pre2022_cat1_dist_100m_v1.tif +2026-01-27 14:04:26,513 INFO: Downloaded to data\covariate_data\Zambia_Covs\zmb_WDPA_pre2022_cat1_dist_100m_v1.tif diff --git a/src_covariates/request_get_covariets.py b/src_covariates/request_get_covariets.py new file mode 100644 index 0000000..b756618 --- /dev/null +++ b/src_covariates/request_get_covariets.py @@ -0,0 +1,79 @@ +# Using requests directly + +import requests +import os +import logging + +file_containing_urls = "worldpop_file_urls.md" + +def get_country_folder(filename): + if filename.startswith("mwi_"): + return "Malawi_Covs" + elif filename.startswith("tza_"): + return "Tanzania_Covs" + elif filename.startswith("moz_"): + return "Mozambique_Covs" + elif filename.startswith("zmb_"): + return "Zambia_Covs" + else: + return None + +def download_file(url, out_path): + # Send HTTP GET request to the URL, streaming the response + response = requests.get(url, stream=True) + # Raise an error if the request failed (e.g., 404 or 500) + response.raise_for_status() + # Create the output directory if it doesn't exist + os.makedirs(os.path.dirname(out_path), exist_ok=True) + # Open the output file in binary write mode + with open(out_path, 'wb') as f: + # Write the file in chunks to avoid loading the whole file into memory + for chunk in response.iter_content(chunk_size=8192): + f.write(chunk) + # Log confirmation of download + logging.info(f"Downloaded to {out_path}") + +def main(): + # Set up logging to file + logging.basicConfig(filename='covariate_download.log', + filemode='a', + format='%(asctime)s %(levelname)s: %(message)s', + level=logging.INFO) + + # Path to the markdown file containing URLs + md_path = file_containing_urls + # Base directory for covariate data + base_dir = os.path.join("data", "covariate_data") + # Open the markdown file for reading + with open(md_path, 'r', encoding='utf-8') as md: + # Iterate over each line in the file + for line in md: + # Remove whitespace from the line + url = line.strip() + # Skip lines that do not start with 'http' (not a URL) + if not url.startswith("http"): + continue + # Extract the filename from the URL + filename = url.split("/")[-1] + # Determine the country folder based on filename prefix + country_folder = get_country_folder(filename) + # Skip if the filename does not match any country prefix + if not country_folder: + continue + # Build the output directory path for the country + out_dir = os.path.join(base_dir, country_folder) + # Build the full output file path + out_path = os.path.join(out_dir, filename) + # If the file already exists, log and skip download + if os.path.exists(out_path): + logging.info(f"Exists: {out_path}") + continue + try: + # Attempt to download the file + download_file(url, out_path) + except Exception as e: + # Log any errors encountered during download + logging.error(f"Failed to download {url}: {e}") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/src_covariates/worldpop_covariets.txt b/src_covariates/worldpop_covariets.txt new file mode 100644 index 0000000..2181c95 --- /dev/null +++ b/src_covariates/worldpop_covariets.txt @@ -0,0 +1,62 @@ +buildings_count_BCB_gl_100m_v1_1 +buildings_count_BCB_ms_100m_v1_1 +buildings_cv_area_BCB_gl_100m_v1_1 +buildings_cv_area_BCB_ms_100m_v1_1 +buildings_cv_area_PIB_gl_100m_v1_1 +buildings_cv_area_PIB_ms_100m_v1_1 +buildings_cv_length_BCB_gl_100m_v1_1 +buildings_cv_length_BCB_ms_100m_v1_1 +buildings_cv_length_PIB_gl_100m_v1_1 +buildings_cv_length_PIB_ms_100m_v1_1 +buildings_density_BCB_gl_100m_v1_1 +buildings_density_BCB_ms_100m_v1_1 +buildings_density_PIB_gl_100m_v1_1 +buildings_density_PIB_ms_100m_v1_1 +buildings_mean_area_BCB_gl_100m_v1_1 +buildings_mean_area_BCB_ms_100m_v1_1 +buildings_mean_area_PIB_gl_100m_v1_1 +buildings_mean_area_PIB_ms_100m_v1_1 +buildings_mean_length_BCB_gl_100m_v1_1 +buildings_mean_length_BCB_ms_100m_v1_1 +buildings_mean_length_PIB_gl_100m_v1_1 +buildings_mean_length_PIB_ms_100m_v1_1 +buildings_total_area_BCB_gl_100m_v1_1 +buildings_total_area_BCB_ms_100m_v1_1 +buildings_total_area_PIB_gl_100m_v1_1 +buildings_total_area_PIB_ms_100m_v1_1 +buildings_total_length_BCB_gl_100m_v1_1 +buildings_total_length_BCB_ms_100m_v1_1 +buildings_total_length_PIB_gl_100m_v1_1 +buildings_total_length_PIB_ms_100m_v1_1 +built_S_dist_2024_GHS_MGW_100m_v1 +built_S_GHS_U_wFGW_100m_v1_2024 +built_S_NRES_GHS_U_wFGW_100m_v1_2024 +built_V_GHS_U_wFGW_100m_v1_2024 +built_V_NRES_GHS_U_wFGW_100m_v1_2024 +coastline_dst_100m_v1 +dist_inland_water_100m_esa_2021_v1 +elevation_merit103_100m_v1 +esalc_11_dst_2022_100m_v1 +esalc_130_dst_2022_100m_v1 +esalc_140_dst_2022_100m_v1 +esalc_150_dst_2022_100m_v1 +esalc_160_dst_2022_100m_v1 +esalc_190_dst_2022_100m_v1 +esalc_200_dst_2022_100m_v1 +esalc_210_dst_2022_100m_v1 +esalc_40_dst_2022_100m_v1 +highway_dist_osm_2023_100m_v1 +inland_water_pct_100m_v1 +ms_roads_count_100m_v1 +ms_roads_density_100m_v1 +ms_roads_dst_100m_v1 +ms_roads_total_length_100m_v1 +ppt_2023_yravg_tc_100m_v1 +rd_intrs_dist_osm_2023_100m_v1 +slope_merit103_100m_v1 +tavg_2023_tlst_100m_v1 +viirs_fvf_2023_100m_v1 +viirs_nvf_2023_100m_v1 +waterbodies_dist_osm_2023_100m_v1 +WDPA_pre2022_cat0_dist_100m_v1 +WDPA_pre2022_cat1_dist_100m_v1 \ No newline at end of file diff --git a/src_covariates/worldpop_file_urls.md b/src_covariates/worldpop_file_urls.md new file mode 100644 index 0000000..0791a31 --- /dev/null +++ b/src_covariates/worldpop_file_urls.md @@ -0,0 +1,375 @@ +# WorldPop Covariate File URLs for Malawi, Tanzania, Mozambique, and Zambia + +1. buildings_count_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/gl/BCB/v1_1/mwi_buildings_count_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/gl/BCB/v1_1/tza_buildings_count_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/gl/BCB/v1_1/moz_buildings_count_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/gl/BCB/v1_1/zmb_buildings_count_BCB_gl_100m_v1_1.tif + +2. buildings_count_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/ms/BCB/v1_1/mwi_buildings_count_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/ms/BCB/v1_1/tza_buildings_count_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/ms/BCB/v1_1/moz_buildings_count_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/ms/BCB/v1_1/zmb_buildings_count_BCB_ms_100m_v1_1.tif + +3. buildings_cv_area_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/gl/BCB/v1_1/mwi_buildings_cv_area_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/gl/BCB/v1_1/tza_buildings_cv_area_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/gl/BCB/v1_1/moz_buildings_cv_area_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/gl/BCB/v1_1/zmb_buildings_cv_area_BCB_gl_100m_v1_1.tif + +4. buildings_cv_area_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/ms/BCB/v1_1/mwi_buildings_cv_area_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/ms/BCB/v1_1/tza_buildings_cv_area_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/ms/BCB/v1_1/moz_buildings_cv_area_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/ms/BCB/v1_1/zmb_buildings_cv_area_BCB_ms_100m_v1_1.tif + +5. buildings_cv_area_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/gl/PIB/v1_1/mwi_buildings_cv_area_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/gl/PIB/v1_1/tza_buildings_cv_area_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/gl/PIB/v1_1/moz_buildings_cv_area_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/gl/PIB/v1_1/zmb_buildings_cv_area_PIB_gl_100m_v1_1.tif + +6. buildings_cv_area_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/ms/PIB/v1_1/mwi_buildings_cv_area_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/ms/PIB/v1_1/tza_buildings_cv_area_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/ms/PIB/v1_1/moz_buildings_cv_area_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/ms/PIB/v1_1/zmb_buildings_cv_area_PIB_ms_100m_v1_1.tif + +7. buildings_cv_length_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/gl/BCB/v1_1/mwi_buildings_cv_length_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/gl/BCB/v1_1/tza_buildings_cv_length_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/gl/BCB/v1_1/moz_buildings_cv_length_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/gl/BCB/v1_1/zmb_buildings_cv_length_BCB_gl_100m_v1_1.tif + +8. buildings_cv_length_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/ms/BCB/v1_1/mwi_buildings_cv_length_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/ms/BCB/v1_1/tza_buildings_cv_length_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/ms/BCB/v1_1/moz_buildings_cv_length_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/ms/BCB/v1_1/zmb_buildings_cv_length_BCB_ms_100m_v1_1.tif + +9. buildings_cv_length_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/gl/PIB/v1_1/mwi_buildings_cv_length_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/gl/PIB/v1_1/tza_buildings_cv_length_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/gl/PIB/v1_1/moz_buildings_cv_length_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/gl/PIB/v1_1/zmb_buildings_cv_length_PIB_gl_100m_v1_1.tif + +10. buildings_cv_length_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/ms/PIB/v1_1/mwi_buildings_cv_length_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/ms/PIB/v1_1/tza_buildings_cv_length_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/ms/PIB/v1_1/moz_buildings_cv_length_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/ms/PIB/v1_1/zmb_buildings_cv_length_PIB_ms_100m_v1_1.tif + +11. buildings_density_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/gl/BCB/v1_1/mwi_buildings_density_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/gl/BCB/v1_1/tza_buildings_density_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/gl/BCB/v1_1/moz_buildings_density_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/gl/BCB/v1_1/zmb_buildings_density_BCB_gl_100m_v1_1.tif + +12. buildings_density_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/ms/BCB/v1_1/mwi_buildings_density_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/ms/BCB/v1_1/tza_buildings_density_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/ms/BCB/v1_1/moz_buildings_density_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/ms/BCB/v1_1/zmb_buildings_density_BCB_ms_100m_v1_1.tif + +13. buildings_density_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/gl/PIB/v1_1/mwi_buildings_density_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/gl/PIB/v1_1/tza_buildings_density_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/gl/PIB/v1_1/moz_buildings_density_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/gl/PIB/v1_1/zmb_buildings_density_PIB_gl_100m_v1_1.tif + +14. buildings_density_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/ms/PIB/v1_1/mwi_buildings_density_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/ms/PIB/v1_1/tza_buildings_density_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/ms/PIB/v1_1/moz_buildings_density_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/ms/PIB/v1_1/zmb_buildings_density_PIB_ms_100m_v1_1.tif + +15. buildings_mean_area_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/gl/BCB/v1_1/mwi_buildings_mean_area_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/gl/BCB/v1_1/tza_buildings_mean_area_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/gl/BCB/v1_1/moz_buildings_mean_area_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/gl/BCB/v1_1/zmb_buildings_mean_area_BCB_gl_100m_v1_1.tif + +16. buildings_mean_area_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/ms/BCB/v1_1/mwi_buildings_mean_area_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/ms/BCB/v1_1/tza_buildings_mean_area_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/ms/BCB/v1_1/moz_buildings_mean_area_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/ms/BCB/v1_1/zmb_buildings_mean_area_BCB_ms_100m_v1_1.tif + +17. buildings_mean_area_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/gl/PIB/v1_1/mwi_buildings_mean_area_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/gl/PIB/v1_1/tza_buildings_mean_area_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/gl/PIB/v1_1/moz_buildings_mean_area_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/gl/PIB/v1_1/zmb_buildings_mean_area_PIB_gl_100m_v1_1.tif + +18. buildings_mean_area_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/ms/PIB/v1_1/mwi_buildings_mean_area_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/ms/PIB/v1_1/tza_buildings_mean_area_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/ms/PIB/v1_1/moz_buildings_mean_area_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/ms/PIB/v1_1/zmb_buildings_mean_area_PIB_ms_100m_v1_1.tif + +19. buildings_mean_length_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/gl/BCB/v1_1/mwi_buildings_mean_length_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/gl/BCB/v1_1/tza_buildings_mean_length_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/gl/BCB/v1_1/moz_buildings_mean_length_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/gl/BCB/v1_1/zmb_buildings_mean_length_BCB_gl_100m_v1_1.tif + +20. buildings_mean_length_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/ms/BCB/v1_1/mwi_buildings_mean_length_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/ms/BCB/v1_1/tza_buildings_mean_length_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/ms/BCB/v1_1/moz_buildings_mean_length_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/ms/BCB/v1_1/zmb_buildings_mean_length_BCB_ms_100m_v1_1.tif + +21. buildings_mean_length_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/gl/PIB/v1_1/mwi_buildings_mean_length_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/gl/PIB/v1_1/tza_buildings_mean_length_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/gl/PIB/v1_1/moz_buildings_mean_length_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/gl/PIB/v1_1/zmb_buildings_mean_length_PIB_gl_100m_v1_1.tif + +22. buildings_mean_length_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/ms/PIB/v1_1/mwi_buildings_mean_length_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/ms/PIB/v1_1/tza_buildings_mean_length_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/ms/PIB/v1_1/moz_buildings_mean_length_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/ms/PIB/v1_1/zmb_buildings_mean_length_PIB_ms_100m_v1_1.tif + +23. buildings_total_area_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/gl/BCB/v1_1/mwi_buildings_total_area_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/gl/BCB/v1_1/tza_buildings_total_area_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/gl/BCB/v1_1/moz_buildings_total_area_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/gl/BCB/v1_1/zmb_buildings_total_area_BCB_gl_100m_v1_1.tif + +24. buildings_total_area_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/ms/BCB/v1_1/mwi_buildings_total_area_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/ms/BCB/v1_1/tza_buildings_total_area_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/ms/BCB/v1_1/moz_buildings_total_area_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/ms/BCB/v1_1/zmb_buildings_total_area_BCB_ms_100m_v1_1.tif + +25. buildings_total_area_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/gl/PIB/v1_1/mwi_buildings_total_area_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/gl/PIB/v1_1/tza_buildings_total_area_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/gl/PIB/v1_1/moz_buildings_total_area_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/gl/PIB/v1_1/zmb_buildings_total_area_PIB_gl_100m_v1_1.tif + +26. buildings_total_area_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/ms/PIB/v1_1/mwi_buildings_total_area_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/ms/PIB/v1_1/tza_buildings_total_area_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/ms/PIB/v1_1/moz_buildings_total_area_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/ms/PIB/v1_1/zmb_buildings_total_area_PIB_ms_100m_v1_1.tif + +27. buildings_total_length_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/gl/BCB/v1_1/mwi_buildings_total_length_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/gl/BCB/v1_1/tza_buildings_total_length_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/gl/BCB/v1_1/moz_buildings_total_length_BCB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/gl/BCB/v1_1/zmb_buildings_total_length_BCB_gl_100m_v1_1.tif + +28. buildings_total_length_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/ms/BCB/v1_1/mwi_buildings_total_length_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/ms/BCB/v1_1/tza_buildings_total_length_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/ms/BCB/v1_1/moz_buildings_total_length_BCB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/ms/BCB/v1_1/zmb_buildings_total_length_BCB_ms_100m_v1_1.tif + +29. buildings_total_length_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/gl/PIB/v1_1/mwi_buildings_total_length_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/gl/PIB/v1_1/tza_buildings_total_length_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/gl/PIB/v1_1/moz_buildings_total_length_PIB_gl_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/gl/PIB/v1_1/zmb_buildings_total_length_PIB_gl_100m_v1_1.tif + +30. buildings_total_length_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/buildings/ms/PIB/v1_1/mwi_buildings_total_length_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/buildings/ms/PIB/v1_1/tza_buildings_total_length_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/buildings/ms/PIB/v1_1/moz_buildings_total_length_PIB_ms_100m_v1_1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/buildings/ms/PIB/v1_1/zmb_buildings_total_length_PIB_ms_100m_v1_1.tif + +31. built_S_dist_2024_GHS_MGW_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/BuiltSettlement/v1/Distance/mwi_built_S_dist_2024_GHS_MGW_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/BuiltSettlement/v1/Distance/mwi_built_S_dist_2018_GHS_MGW_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/BuiltSettlement/v1/Distance/tza_built_S_dist_2024_GHS_MGW_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/BuiltSettlement/v1/Distance/tza_built_S_dist_2018_GHS_MGW_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/BuiltSettlement/v1/Distance/moz_built_S_dist_2024_GHS_MGW_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/BuiltSettlement/v1/Distance/moz_built_S_dist_2018_GHS_MGW_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/BuiltSettlement/v1/Distance/zmb_built_S_dist_2024_GHS_MGW_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/BuiltSettlement/v1/Distance/zmb_built_S_dist_2018_GHS_MGW_100m_v1.tif + +32. built_S_GHS_U_wFGW_100m_v1_2024.tif 2024 and 2018 +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/BuiltSettlement/v1/Built_surface/mwi_built_S_GHS_U_wFGW_100m_v1_2024.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/BuiltSettlement/v1/Built_surface/mwi_built_S_GHS_U_wFGW_100m_v1_2018.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/BuiltSettlement/v1/Built_surface/tza_built_S_GHS_U_wFGW_100m_v1_2024.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/BuiltSettlement/v1/Built_surface/tza_built_S_GHS_U_wFGW_100m_v1_2018.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/BuiltSettlement/v1/Built_surface/moz_built_S_GHS_U_wFGW_100m_v1_2024.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/BuiltSettlement/v1/Built_surface/moz_built_S_GHS_U_wFGW_100m_v1_2018.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/BuiltSettlement/v1/Built_surface/zmb_built_S_GHS_U_wFGW_100m_v1_2024.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/BuiltSettlement/v1/Built_surface/zmb_built_S_GHS_U_wFGW_100m_v1_2018.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/BuiltSettlement/v1/Built_surface//mwi_built_S_GHS_U_wFGW_100m_v1_2018.tif + + +33. built_S_NRES_GHS_U_wFGW_100m_v1_2024.tif + + +34. built_V_GHS_U_wFGW_100m_v1_2024.tif +built_V_GHS_U_wFGW_100m_v1_2024.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/BuiltSettlement/v1/Built_volume/mwi_built_V_GHS_U_wFGW_100m_v1_2024.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/BuiltSettlement/v1/Built_volume/mwi_built_V_GHS_U_wFGW_100m_v1_2018.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/BuiltSettlement/v1/Built_volume/tza_built_V_GHS_U_wFGW_100m_v1_2024.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/BuiltSettlement/v1/Built_volume/tza_built_V_GHS_U_wFGW_100m_v1_2018.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/BuiltSettlement/v1/Built_volume/moz_built_V_GHS_U_wFGW_100m_v1_2024.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/BuiltSettlement/v1/Built_volume/moz_built_V_GHS_U_wFGW_100m_v1_2018.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/BuiltSettlement/v1/Built_volume/zmb_built_V_GHS_U_wFGW_100m_v1_2024.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/BuiltSettlement/v1/Built_volume/zmb_built_V_GHS_U_wFGW_100m_v1_2018.tif + +35. built_V_NRES_GHS_U_wFGW_100m_v1_2024.tif + + +36. coastline_dst_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Coastline/v1/Distance/mwi_coastline_dst_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/Coastline/v1/Distance/tza_coastline_dst_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/Coastline/v1/Distance/moz_coastline_dst_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/Coastline/v1/Distance/zmb_coastline_dst_100m_v1.tif + +37. dist_inland_water_100m_esa_2021_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Inland_water/esa_worldcover/v1/Dist/mwi_dist_inland_water_100m_esa_2021_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/Inland_water/esa_worldcover/v1/Dist/tza_dist_inland_water_100m_esa_2021_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/Inland_water/esa_worldcover/v1/Dist/moz_dist_inland_water_100m_esa_2021_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/Inland_water/esa_worldcover/v1/Dist/zmb_dist_inland_water_100m_esa_2021_v1.tif + +38. elevation_merit103_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Elevation/MERIT_DEM/v1/mwi_elevation_merit103_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/Elevation/MERIT_DEM/v1/tza_elevation_merit103_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/Elevation/MERIT_DEM/v1/moz_elevation_merit103_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/Elevation/MERIT_DEM/v1/zmb_elevation_merit103_100m_v1.tif + +39. esalc_11_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Land_Cover/ESA/v1/2022/mwi_esalc_11_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/Land_Cover/ESA/v1/2022/tza_esalc_11_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/Land_Cover/ESA/v1/2022/moz_esalc_11_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/Land_Cover/ESA/v1/2022/zmb_esalc_11_dst_2022_100m_v1.tif + +40. esalc_130_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Land_Cover/ESA/v1/2022/mwi_esalc_130_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/Land_Cover/ESA/v1/2022/tza_esalc_130_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/Land_Cover/ESA/v1/2022/moz_esalc_130_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/Land_Cover/ESA/v1/2022/zmb_esalc_130_dst_2022_100m_v1.tif + +41. esalc_140_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Land_Cover/ESA/v1/2022/mwi_esalc_140_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/Land_Cover/ESA/v1/2022/tza_esalc_140_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/Land_Cover/ESA/v1/2022/moz_esalc_140_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/Land_Cover/ESA/v1/2022/zmb_esalc_140_dst_2022_100m_v1.tif + +42. esalc_150_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Land_Cover/ESA/v1/2022/mwi_esalc_150_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/Land_Cover/ESA/v1/2022/tza_esalc_150_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/Land_Cover/ESA/v1/2022/moz_esalc_150_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/Land_Cover/ESA/v1/2022/zmb_esalc_150_dst_2022_100m_v1.tif + +43. esalc_160_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Land_Cover/ESA/v1/2022/mwi_esalc_160_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/Land_Cover/ESA/v1/2022/tza_esalc_160_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/Land_Cover/ESA/v1/2022/moz_esalc_160_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/Land_Cover/ESA/v1/2022/zmb_esalc_160_dst_2022_100m_v1.tif + +44. esalc_190_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Land_Cover/ESA/v1/2022/mwi_esalc_190_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/Land_Cover/ESA/v1/2022/tza_esalc_190_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/Land_Cover/ESA/v1/2022/moz_esalc_190_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/Land_Cover/ESA/v1/2022/zmb_esalc_190_dst_2022_100m_v1.tif + +45. esalc_200_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Land_Cover/ESA/v1/2022/mwi_esalc_200_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/Land_Cover/ESA/v1/2022/tza_esalc_200_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/Land_Cover/ESA/v1/2022/moz_esalc_200_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/Land_Cover/ESA/v1/2022/zmb_esalc_200_dst_2022_100m_v1.tif + +46. esalc_210_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Land_Cover/ESA/v1/2022/mwi_esalc_210_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/Land_Cover/ESA/v1/2022/tza_esalc_210_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/Land_Cover/ESA/v1/2022/moz_esalc_210_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/Land_Cover/ESA/v1/2022/zmb_esalc_210_dst_2022_100m_v1.tif + +47. esalc_40_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Land_Cover/ESA/v1/2022/mwi_esalc_40_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/Land_Cover/ESA/v1/2022/tza_esalc_40_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/Land_Cover/ESA/v1/2022/moz_esalc_40_dst_2022_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/Land_Cover/ESA/v1/2022/zmb_esalc_40_dst_2022_100m_v1.tif + +48. highway_dist_osm_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/OSM/v1/mwi_highway_dist_osm_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/OSM/v1/tza_highway_dist_osm_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/OSM/v1/moz_highway_dist_osm_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/OSM/v1/zmb_highway_dist_osm_2023_100m_v1.tif + +49. inland_water_pct_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Inland_water/esa_worldcover/v1/Dist/mwi_dist_inland_water_100m_esa_2021_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/OSM/v1/mwi_waterbodies_dist_osm_2023_100m_v1.tif + +50. ms_roads_count_100m_v1.tif + +51. ms_roads_density_100m_v1.tif + +52. ms_roads_dst_100m_v1.tif + +53. ms_roads_total_length_100m_v1.tif + +54. ppt_2023_yravg_tc_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Climate/Precipitation/TerraClim/v1//mwi_ppt_2023_yravg_tc_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Climate/Precipitation/TerraClim/v1//mwi_ppt_2018_yravg_tc_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/Climate/Precipitation/TerraClim/v1/tza_ppt_2023_yravg_tc_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/Climate/Precipitation/TerraClim/v1/moz_ppt_2023_yravg_tc_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/Climate/Precipitation/TerraClim/v1/zmb_ppt_2023_yravg_tc_100m_v1.tif + +55. rd_intrs_dist_osm_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/OSM/v1/mwi_rd_intrs_dist_osm_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/OSM/v1/tza_rd_intrs_dist_osm_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/OSM/v1/moz_rd_intrs_dist_osm_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/OSM/v1/zmb_rd_intrs_dist_osm_2023_100m_v1.tif + +56. slope_merit103_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Slope/MERIT_DEM/v1/mwi_slope_merit103_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/Slope/MERIT_DEM/v1/tza_slope_merit103_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/Slope/MERIT_DEM/v1/moz_slope_merit103_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/Slope/MERIT_DEM/v1/zmb_slope_merit103_100m_v1.tif + +57. tavg_2023_tlst_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Climate/Temperature/TerraLST/v1//mwi_tavg_2023_tlst_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/Climate/Temperature/TerraLST/v1//mwi_tavg_2018_tlst_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/Climate/Temperature/TerraLST/v1/tza_tavg_2023_tlst_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/Climate/Temperature/TerraLST/v1/moz_tavg_2023_tlst_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/Climate/Temperature/TerraLST/v1/zmb_tavg_2023_tlst_100m_v1.tif + +58. viirs_fvf_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/VIIRS/v1/fvf/mwi_viirs_fvf_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/VIIRS/v1/fvf/mwi_viirs_fvf_2018_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/VIIRS/v1/fvf/tza_viirs_fvf_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/VIIRS/v1/fvf/tza_viirs_fvf_2018_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/VIIRS/v1/fvf/moz_viirs_fvf_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/VIIRS/v1/fvf/moz_viirs_fvf_2018_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/VIIRS/v1/fvf/zmb_viirs_fvf_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/VIIRS/v1/fvf/zmb_viirs_fvf_2018_100m_v1.tif + + +59. viirs_nvf_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/VIIRS/v1/nvf//mwi_viirs_nvf_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/VIIRS/v1/nvf//mwi_viirs_nvf_2018_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/VIIRS/v1/nvf/tza_viirs_nvf_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/VIIRS/v1/nvf/tza_viirs_nvf_2018_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/VIIRS/v1/nvf/moz_viirs_nvf_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/VIIRS/v1/nvf/moz_viirs_nvf_2018_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/VIIRS/v1/nvf/zmb_viirs_nvf_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/VIIRS/v1/nvf/zmb_viirs_nvf_2018_100m_v1.tif + +60. waterbodies_dist_osm_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/OSM/v1/mwi_waterbodies_dist_osm_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/OSM/v1/tza_waterbodies_dist_osm_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/OSM/v1/moz_waterbodies_dist_osm_2023_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/OSM/v1/zmb_waterbodies_dist_osm_2023_100m_v1.tif + +61. WDPA_pre2022_cat0_dist_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/WDPA/v1/cat0//mwi_WDPA_pre2022_cat0_dist_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/WDPA/v1/cat0/tza_WDPA_pre2022_cat0_dist_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/WDPA/v1/cat0/moz_WDPA_pre2022_cat0_dist_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/WDPA/v1/cat0/zmb_WDPA_pre2022_cat0_dist_100m_v1.tif + +62. WDPA_pre2022_cat1_dist_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MWI/WDPA/v1/cat1//mwi_WDPA_pre2022_cat1_dist_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/TZA/WDPA/v1/cat1/tza_WDPA_pre2022_cat1_dist_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/WDPA/v1/cat1/moz_WDPA_pre2022_cat1_dist_100m_v1.tif +https://data.worldpop.org/GIS/Covariates/Global_2015_2030/ZMB/WDPA/v1/cat1/zmb_WDPA_pre2022_cat1_dist_100m_v1.tif diff --git a/utils.R b/utils.R new file mode 100644 index 0000000..8f9f77b --- /dev/null +++ b/utils.R @@ -0,0 +1,84 @@ +library(sf) + +generate_buffered_country_boundary <- function( + shape_path, + file_name, + buffer +){ + #' Produce buffered country boundary shapefile by dissolving EA geometries and + #' adding 10km buffer + #' + ea_geoms <- st_read(file.path(shape_path, "2018_MPHC_EAs_Final_for_Use.shp")) + country_buffer <- ea_geoms %>% + st_union() %>% + st_buffer(buffer) + st_write(country_buffer, file.path(shape_path, file_name)) + return(country_buffer) +} + +rbind_zomba_csvs <- function(csv_dir, output_file){ + #' Produce rbind csv file for zomba from 14 files provided by NSO in "zomba_csv" + #' folder. + #' Headers are normalised, NA rows are removed, and then rbound together to + #' make "zomba_rbind_data.csv" file. + if (!dir.exists(csv_dir)) { + stop("Directory does not exist: ", csv_dir) + } + + output_path <- file.path(output_file) + csv_files <- list.files( + csv_dir, + pattern = "\\.csv$", + full.names = TRUE, + ignore.case = TRUE + ) + csv_files <- sort(csv_files) + + if (length(csv_files) == 0) { + stop("No CSV files found in: ", csv_dir) + } + + zomba_data_list <- lapply( + csv_files, + function(csv_file) { + zomba_data <- read.csv(csv_file, stringsAsFactors = FALSE, check.names = FALSE) + # change headers to lowercase and replace spaces to _ to normalise + names(zomba_data) <- gsub("\\s+", "_", tolower(trimws(names(zomba_data)))) + # "Nkapita.csv" had "household_name" instead of "household_number" like + # the rest + names(zomba_data)[names(zomba_data) == "household_name"] <- "household_number" + # remove rows where every field is blank or missing + empty_rows <- apply( + zomba_data, + 1, + function(row) all(is.na(row) | trimws(as.character(row)) == "") + ) + zomba_data <- zomba_data[!empty_rows, , drop = FALSE] + zomba_data + } + ) + + # Look at the first file and determine what columns are expected + expected_columns <- names(zomba_data_list[[1]]) + + matching_columns <- vapply( + zomba_data_list, + function(zomba_data) identical(names(zomba_data), expected_columns), + logical(1) + ) + + # Check that every CSV has the same normalized columns as the first file and + # stop with the filenames of any CSVs that still do not match. + if (!all(matching_columns)) { + mismatched_files <- basename(csv_files[!matching_columns]) + stop( + "CSV files do not share identical columns and cannot be row-bound with rbind: ", + paste(mismatched_files, collapse = ", ") + ) + } + + zomba_rbind_data <- do.call(rbind, zomba_data_list) + write.csv(zomba_rbind_data, output_path, row.names = FALSE) + + return() +}