From 58a571dfb603bad56976da1fb652b4011cca274d Mon Sep 17 00:00:00 2001 From: TSGreen Date: Thu, 1 Jan 2026 17:32:21 +0000 Subject: [PATCH 01/31] chore: gitignore data dir and Rproj file --- .gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .gitignore 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/* From cd7e64dac708db0d627748b34c9a46d3cadb641d Mon Sep 17 00:00:00 2001 From: TSGreen Date: Thu, 1 Jan 2026 17:32:52 +0000 Subject: [PATCH 02/31] feat: Add script for package installation --- load_required_libraries.R | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 load_required_libraries.R diff --git a/load_required_libraries.R b/load_required_libraries.R new file mode 100644 index 0000000..a9edc06 --- /dev/null +++ b/load_required_libraries.R @@ -0,0 +1,41 @@ +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 +) + +# Execute code to load (and install) libraries +load_libraries(required_libraries) From 550946e30ee6f066a05c009a0dc3998dae2f6bc8 Mon Sep 17 00:00:00 2001 From: TSGreen Date: Thu, 1 Jan 2026 17:33:16 +0000 Subject: [PATCH 03/31] refactor: Update file paths for ONS versions --- 00_Data_Processing2.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/00_Data_Processing2.R b/00_Data_Processing2.R index bbf1c52..8d66ffa 100644 --- a/00_Data_Processing2.R +++ b/00_Data_Processing2.R @@ -9,8 +9,8 @@ library(tidyverse) options(scipen = 999) # turn off scientific notation for all variables #Specify Drive Path -drive_path <- "//Internal/MALAWI/Ortis/" -input_path <- paste0(drive_path, "Input_Data/Surveys/") +drive_path <- "./data/" +input_path <- paste0(drive_path, "mnso_ons_data.20251216.dat/") output_path <- paste0(drive_path, "/Output_Data/") shapefile_path <- paste0(drive_path, "Input_Data/Shapefiles/") From 67976a765cb9e3327ba2b34ab11ef89aab1103b7 Mon Sep 17 00:00:00 2001 From: TSGreen Date: Fri, 9 Jan 2026 10:37:07 +0000 Subject: [PATCH 04/31] refactor: Enable execution of 00 script on local machines --- 00_Data_Processing2.R | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/00_Data_Processing2.R b/00_Data_Processing2.R index 8d66ffa..8f3eb10 100644 --- a/00_Data_Processing2.R +++ b/00_Data_Processing2.R @@ -10,16 +10,16 @@ options(scipen = 999) # turn off scientific notation for all variables #Specify Drive Path drive_path <- "./data/" -input_path <- paste0(drive_path, "mnso_ons_data.20251216.dat/") +input_path <- paste0(drive_path, "MNSO-Data/") output_path <- paste0(drive_path, "/Output_Data/") -shapefile_path <- paste0(drive_path, "Input_Data/Shapefiles/") +shapefile_path <- paste0(drive_path, "Shapefiles/") #Load datasets mphc_2018 <- read_dta(paste0(input_path, "mphc2018Data_AllRegions.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, "EA_Shapefile.shp")) +ea <- st_read(file.path(shapefile_path, "2018_MPHC_EAs_Final_for_Use.shp")) # replaces "EA_Shapefile.shp" ##################################################################################### #################################################################################### @@ -29,7 +29,7 @@ ea <- st_read(file.path(shapefile_path, "EA_Shapefile.shp")) 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), @@ -56,7 +56,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 @@ -128,10 +128,11 @@ mphc_pop_no_gps <- mphc_pop_no_gps %>% 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) + 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")) @@ -143,6 +144,16 @@ mphc_pop_no_gps <- mphc_pop_no_gps %>% #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 %>% From 65b4f2959e45f98f8d6610e04e0e07c155b2f532 Mon Sep 17 00:00:00 2001 From: Timothy S Green <62939263+TSGreen@users.noreply.github.com> Date: Fri, 9 Jan 2026 15:33:12 +0000 Subject: [PATCH 05/31] Add MIT License to the project --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE 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. From 66ab0b264e8e687b3fe106f720960ffba23c0a01 Mon Sep 17 00:00:00 2001 From: TSGreen Date: Fri, 9 Jan 2026 15:34:24 +0000 Subject: [PATCH 06/31] refactor: Update building mosaic script for compatibility with existing data --- 01_Raster_Mosaicking_Buildings_2018.R | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/01_Raster_Mosaicking_Buildings_2018.R b/01_Raster_Mosaicking_Buildings_2018.R index 0fc481e..5d96165 100644 --- a/01_Raster_Mosaicking_Buildings_2018.R +++ b/01_Raster_Mosaicking_Buildings_2018.R @@ -1,26 +1,26 @@ -#Script to mosaic rasters using neighboring countries +# Script to mosaic rasters using neighboring countries library(terra) library(sf) library(tictoc) # 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 <- paste0(drive_path, "/Shapefiles/") ## Shapefile path +result_path <- paste0(drive_path, "/Mosaic_Buildings/") # Result path +building_path <- paste0(drive_path, "/covariate_data/") #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 <- st_read(paste0(shp_path, "LU.shp")) # replacing: "Country_Shapefile_Buffer_10km.shp" +r1 <- rast(paste0(building_path, "mwi_buildings_count_BCB_ms_100m_v1_1.tif")) # replacing: "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/Buildings", "Tanzania_Covs/Buildings", + "Mozambique_Covs/Buildings", "Zambia_Covs/Buildings") # Initialize a list to store raster file names From 14b7eb0062db6095fb0503099bce20bbb231f877 Mon Sep 17 00:00:00 2001 From: TSGreen Date: Thu, 15 Jan 2026 16:59:21 +0000 Subject: [PATCH 07/31] refactor: Update paths to EA shapefiles and data dir --- 01_Raster_Mosaicking_Workflow_2018.R | 2 +- 01_Raster_Mosaicking_Workflow_2024.R | 2 +- 02_Covariates_Extraction.R | 6 +++--- 03_HH_Model_Workflow_2024c.R | 2 +- 03_Pop_Model_Workflow_2018.R | 4 ++-- 04_Covs_Stack_Raster_cropping.R | 6 +++--- 04_Rasterize.R | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/01_Raster_Mosaicking_Workflow_2018.R b/01_Raster_Mosaicking_Workflow_2018.R index cf0b1b9..e4a2094 100644 --- a/01_Raster_Mosaicking_Workflow_2018.R +++ b/01_Raster_Mosaicking_Workflow_2018.R @@ -3,7 +3,7 @@ library(sf) library(tictoc) # Specify data path -drive_path <- "//Working/MALAWI/Ortis/" +drive_path <- "./data/" 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 diff --git a/01_Raster_Mosaicking_Workflow_2024.R b/01_Raster_Mosaicking_Workflow_2024.R index 63c957b..3824dfd 100644 --- a/01_Raster_Mosaicking_Workflow_2024.R +++ b/01_Raster_Mosaicking_Workflow_2024.R @@ -3,7 +3,7 @@ library(sf) library(tictoc) # Specify data path -drive_path <- "//Working/MALAWI/Ortis/" +drive_path <- "./data/" 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 diff --git a/02_Covariates_Extraction.R b/02_Covariates_Extraction.R index abcfc97..539dbab 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")) diff --git a/03_HH_Model_Workflow_2024c.R b/03_HH_Model_Workflow_2024c.R index e90df29..39bdccf 100644 --- a/03_HH_Model_Workflow_2024c.R +++ b/03_HH_Model_Workflow_2024c.R @@ -17,7 +17,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/") 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..4bf0673 100644 --- a/04_Rasterize.R +++ b/04_Rasterize.R @@ -8,13 +8,13 @@ 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")) From 4cfbede82affee1e9f1e73af9bf2774f9391be58 Mon Sep 17 00:00:00 2001 From: Amanda Baizan Edge Date: Tue, 27 Jan 2026 14:50:15 +0000 Subject: [PATCH 08/31] List of covariets needed for model and urls to access data in WP website --- src_covariates/worldpop_covariets.txt | 62 +++++ src_covariates/worldpop_file_urls.md | 373 ++++++++++++++++++++++++++ 2 files changed, 435 insertions(+) create mode 100644 src_covariates/worldpop_covariets.txt create mode 100644 src_covariates/worldpop_file_urls.md 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..051f814 --- /dev/null +++ b/src_covariates/worldpop_file_urls.md @@ -0,0 +1,373 @@ +# 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 + +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 From ca20e6545a2baf28f33ee4225750ecff9b98ba92 Mon Sep 17 00:00:00 2001 From: Amanda Baizan Edge Date: Tue, 27 Jan 2026 14:51:03 +0000 Subject: [PATCH 09/31] Script to download data using urls and datalog showing which ones were downloaded successfully. --- src_covariates/covariate_download.log | 243 ++++++++++++++++++++++++ src_covariates/request_get_covariets.py | 79 ++++++++ 2 files changed, 322 insertions(+) create mode 100644 src_covariates/covariate_download.log create mode 100644 src_covariates/request_get_covariets.py 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 From 5975b6f844b9814ff585078b7c8ed669734d3d6c Mon Sep 17 00:00:00 2001 From: Amanda Baizan Edge Date: Wed, 4 Feb 2026 10:07:43 +0000 Subject: [PATCH 10/31] Added path to covariate --- src_covariates/worldpop_file_urls.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src_covariates/worldpop_file_urls.md b/src_covariates/worldpop_file_urls.md index 051f814..0791a31 100644 --- a/src_covariates/worldpop_file_urls.md +++ b/src_covariates/worldpop_file_urls.md @@ -298,6 +298,8 @@ https://data.worldpop.org/GIS/Covariates/Global_2015_2030/MOZ/OSM/v1/moz_highway 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 From 2df0710201c045bf85be4a4e7475f2dd2beeee05 Mon Sep 17 00:00:00 2001 From: TSGreen Date: Thu, 5 Feb 2026 15:03:42 +0000 Subject: [PATCH 11/31] feat: Output 10km buffered country boundary geometry Include check for file and create if not --- 01_Raster_Mosaicking_Buildings_2018.R | 10 +++++++++- 01_Raster_Mosaicking_Buildings_2024.R | 9 ++++++++- 01_Raster_Mosaicking_Workflow_2018.R | 10 +++++++++- 01_Raster_Mosaicking_Workflow_2024.R | 10 +++++++++- utils.R | 16 ++++++++++++++++ 5 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 utils.R diff --git a/01_Raster_Mosaicking_Buildings_2018.R b/01_Raster_Mosaicking_Buildings_2018.R index 5d96165..075344e 100644 --- a/01_Raster_Mosaicking_Buildings_2018.R +++ b/01_Raster_Mosaicking_Buildings_2018.R @@ -4,6 +4,8 @@ library(terra) library(sf) library(tictoc) +source("utils.R") + # Specify data path drive_path <- "./data" base_path <- paste0(drive_path) ## Base path where the folders are located @@ -12,7 +14,13 @@ result_path <- paste0(drive_path, "/Mosaic_Buildings/") # Result path building_path <- paste0(drive_path, "/covariate_data/") #Load data -boundary <- st_read(paste0(shp_path, "LU.shp")) # replacing: "Country_Shapefile_Buffer_10km.shp" +boundary_data_filename <- "Country_Shapefile_Buffer_10km.shp" +if(file.exists(paste0(shp_path, boundary_data_filename))) { + boundary <- st_read(paste0(shp_path, boundary_data_filename)) +} else { + boundary <- generate_buffered_country_boundary(shp_path, boundary_data_filename) +} + r1 <- rast(paste0(building_path, "mwi_buildings_count_BCB_ms_100m_v1_1.tif")) # replacing: "mwi_buildings_count_2018_glv2_5_t0_5_C_100m_v1.tif" #Reproject boundary to r1 diff --git a/01_Raster_Mosaicking_Buildings_2024.R b/01_Raster_Mosaicking_Buildings_2024.R index 45140c7..5d42dbc 100644 --- a/01_Raster_Mosaicking_Buildings_2024.R +++ b/01_Raster_Mosaicking_Buildings_2024.R @@ -2,6 +2,8 @@ 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 @@ -10,7 +12,12 @@ result_path <- paste0(drive_path, "Input_Data/Mosaic_Buildings_2024/") # Result building_path <- paste0(drive_path, "Input_Data/Malawi_Covs/2024_Buildings/") #Load data -boundary <- st_read(paste0(shp_path, "Country_Shapefile_Buffer_10km.shp")) +boundary_data_filename <- "Country_Shapefile_Buffer_10km.shp" +if(file.exists(paste0(shp_path, boundary_data_filename))) { + boundary <- st_read(paste0(shp_path, boundary_data_filename)) +} else { + boundary <- generate_buffered_country_boundary(shp_path, boundary_data_filename) +} r1 <- rast(paste0(building_path, "mwi_buildings_count_2023_glv2_5_t0_5_C_100m_v1.tif")) #Reproject boundary to r1 diff --git a/01_Raster_Mosaicking_Workflow_2018.R b/01_Raster_Mosaicking_Workflow_2018.R index e4a2094..bffc57b 100644 --- a/01_Raster_Mosaicking_Workflow_2018.R +++ b/01_Raster_Mosaicking_Workflow_2018.R @@ -2,6 +2,8 @@ library(terra) library(sf) library(tictoc) +source("utils.R") + # Specify data path drive_path <- "./data/" base_path <- paste0(drive_path, "Input_Data/") ## Base path where the folders are located @@ -10,7 +12,13 @@ result_path <- paste0(drive_path, "Input_Data/Mosaic_Covariates_2018/") # Result building_path <- paste0(drive_path, "Input_Data/Malawi_Covs/2024_Buildings/") #Load data -boundary <- st_read(paste0(shp_path, "Country_Shapefile_Buffer_10km.shp")) +boundary_data_filename <- "Country_Shapefile_Buffer_10km.shp" +if(file.exists(paste0(shp_path, boundary_data_filename))) { + boundary <- st_read(paste0(shp_path, boundary_data_filename)) +} else { + boundary <- generate_buffered_country_boundary(shp_path, boundary_data_filename) +} + r1 <- rast(paste0(building_path, "mwi_buildings_count_2023_glv2_5_t0_5_C_100m_v1.tif")) #Reproject boundary to r1 diff --git a/01_Raster_Mosaicking_Workflow_2024.R b/01_Raster_Mosaicking_Workflow_2024.R index 3824dfd..c7de191 100644 --- a/01_Raster_Mosaicking_Workflow_2024.R +++ b/01_Raster_Mosaicking_Workflow_2024.R @@ -2,6 +2,8 @@ library(terra) library(sf) library(tictoc) +source("utils.R") + # Specify data path drive_path <- "./data/" base_path <- paste0(drive_path, "Input_Data/") ## Base path where the folders are located @@ -10,7 +12,13 @@ result_path <- paste0(drive_path, "Input_Data/Mosaic_Covariates_2024/") # Result building_path <- paste0(drive_path, "Input_Data/Malawi_Covs/2024_Buildings/") #Load data -boundary <- st_read(paste0(shp_path, "Country_Shapefile_Buffer_10km.shp")) +boundary_data_filename <- "Country_Shapefile_Buffer_10km.shp" +if(file.exists(paste0(shp_path, boundary_data_filename))) { + boundary <- st_read(paste0(shp_path, boundary_data_filename)) +} else { + boundary <- generate_buffered_country_boundary(shp_path, boundary_data_filename) +} + r1 <- rast(paste0(building_path, "mwi_buildings_count_2023_glv2_5_t0_5_C_100m_v1.tif")) #Reproject boundary to r1 diff --git a/utils.R b/utils.R new file mode 100644 index 0000000..18fb336 --- /dev/null +++ b/utils.R @@ -0,0 +1,16 @@ +library(sf) + +generate_buffered_country_boundary <- function( + shape_path, + file_name = "Country_Shapefile_Buffer_10km.shp" +){ + #' 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(10E3) + st_write(country_buffer, file.path(shape_path, file_name)) + return(country_buffer) +} From 3415fcd800d885ca5200d41a7da6c8c5937b2f35 Mon Sep 17 00:00:00 2001 From: TSGreen Date: Fri, 6 Feb 2026 11:55:49 +0000 Subject: [PATCH 12/31] refactor: Enable building raster mosaicing --- 01_Raster_Mosaicking_Buildings_2018.R | 21 +++++++++++++-------- 01_Raster_Mosaicking_Buildings_2024.R | 21 +++++++++++++-------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/01_Raster_Mosaicking_Buildings_2018.R b/01_Raster_Mosaicking_Buildings_2018.R index 075344e..733b75a 100644 --- a/01_Raster_Mosaicking_Buildings_2018.R +++ b/01_Raster_Mosaicking_Buildings_2018.R @@ -9,26 +9,26 @@ source("utils.R") # Specify data path drive_path <- "./data" base_path <- paste0(drive_path) ## Base path where the folders are located -shp_path <- paste0(drive_path, "/Shapefiles/") ## Shapefile path -result_path <- paste0(drive_path, "/Mosaic_Buildings/") # Result path -building_path <- paste0(drive_path, "/covariate_data/") +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_data_filename <- "Country_Shapefile_Buffer_10km.shp" -if(file.exists(paste0(shp_path, boundary_data_filename))) { - boundary <- st_read(paste0(shp_path, boundary_data_filename)) +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(shp_path, boundary_data_filename) } -r1 <- rast(paste0(building_path, "mwi_buildings_count_BCB_ms_100m_v1_1.tif")) # replacing: "mwi_buildings_count_2018_glv2_5_t0_5_C_100m_v1.tif" +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/Buildings", "Tanzania_Covs/Buildings", - "Mozambique_Covs/Buildings", "Zambia_Covs/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 @@ -73,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 5d42dbc..d810846 100644 --- a/01_Raster_Mosaicking_Buildings_2024.R +++ b/01_Raster_Mosaicking_Buildings_2024.R @@ -5,20 +5,20 @@ 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_data_filename <- "Country_Shapefile_Buffer_10km.shp" -if(file.exists(paste0(shp_path, boundary_data_filename))) { - boundary <- st_read(paste0(shp_path, boundary_data_filename)) +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(shp_path, boundary_data_filename) } -r1 <- rast(paste0(building_path, "mwi_buildings_count_2023_glv2_5_t0_5_C_100m_v1.tif")) +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)) @@ -70,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 From 5e20b8a00e3111e26ea1af379a243db63d7bb23f Mon Sep 17 00:00:00 2001 From: TSGreen Date: Mon, 9 Feb 2026 14:09:43 +0000 Subject: [PATCH 13/31] refactor: Enable covariate mosaicing --- 01_Raster_Mosaicking_Workflow_2018.R | 21 +++++++++++++-------- 01_Raster_Mosaicking_Workflow_2024.R | 21 +++++++++++++-------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/01_Raster_Mosaicking_Workflow_2018.R b/01_Raster_Mosaicking_Workflow_2018.R index bffc57b..4362ab7 100644 --- a/01_Raster_Mosaicking_Workflow_2018.R +++ b/01_Raster_Mosaicking_Workflow_2018.R @@ -6,20 +6,20 @@ source("utils.R") # Specify data path drive_path <- "./data/" -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/") +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_data_filename <- "Country_Shapefile_Buffer_10km.shp" -if(file.exists(paste0(shp_path, boundary_data_filename))) { - boundary <- st_read(paste0(shp_path, boundary_data_filename)) +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(shp_path, boundary_data_filename) } -r1 <- rast(paste0(building_path, "mwi_buildings_count_2023_glv2_5_t0_5_C_100m_v1.tif")) +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)) @@ -82,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 c7de191..e798833 100644 --- a/01_Raster_Mosaicking_Workflow_2024.R +++ b/01_Raster_Mosaicking_Workflow_2024.R @@ -6,20 +6,20 @@ source("utils.R") # Specify data path drive_path <- "./data/" -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/") +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_data_filename <- "Country_Shapefile_Buffer_10km.shp" -if(file.exists(paste0(shp_path, boundary_data_filename))) { - boundary <- st_read(paste0(shp_path, boundary_data_filename)) +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(shp_path, boundary_data_filename) } -r1 <- rast(paste0(building_path, "mwi_buildings_count_2023_glv2_5_t0_5_C_100m_v1.tif")) +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)) @@ -82,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) From 89e76850eff465e46604e97cb432503985410a94 Mon Sep 17 00:00:00 2001 From: TSGreen Date: Wed, 11 Feb 2026 17:32:40 +0000 Subject: [PATCH 14/31] refactor: Enable run through of 00 preprocessing scripts --- 00_Data_Processing.R | 71 ++++---- 00_Data_Processing2.R | 352 ++++++++++++++++++++++---------------- load_required_libraries.R | 3 +- 3 files changed, 241 insertions(+), 185 deletions(-) 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 d4c5b02..d7b5aa5 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) @@ -10,24 +12,20 @@ library(tidyverse) options(scipen = 999) # turn off scientific notation for all variables #Specify Drive Path -drive_path <- "./data/" -input_path <- paste0(drive_path, "MNSO-Data/") -output_path <- paste0(drive_path, "/Output_Data/") -shapefile_path <- paste0(drive_path, "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")) +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" -#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")) +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")) + ##################################################################################### #################################################################################### @@ -110,42 +108,47 @@ mphc_pop_no_gps <- mphc_pop_no_gps %>% # ============================================================== ---------- -# 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 - -#Fix corrupt geometries -#st_make_valid(ea) +#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 -#Turn off invalid geometries -# sf::sf_use_s2(FALSE) + #Fix corrupt geometries + st_make_valid(ea) -#transform -# mphc_2018_sf <- st_transform(mphc_2018_sf, crs = st_crs(ea)) + #Turn off invalid geometries + sf::sf_use_s2(FALSE) -# EA Nearest Neighbor Assignment -# nearest_indices <- st_nearest_feature(mphc_2018_sf, ea) + #transform + mphc_2018_sf <- st_transform(mphc_2018_sf, crs = st_crs(ea)) -# Extract the EA_CODE of the nearest polygons -# nearest_ids <- ea$EA_CODE[nearest_indices] + # EA Nearest Neighbor Assignment + nearest_indices <- st_nearest_feature(mphc_2018_sf, ea) -# Add the EA_CODE to data -# mphc_2018_sf$EA_CODE <- nearest_ids + # Extract the EA_CODE of the nearest polygons + nearest_ids <- ea$EA_CODE[nearest_indices] -#Write to file -#st_write(mphc_2018_sf , -# dsn = file.path(output_path, "mphc_2018_sf_ea.gpkg"), -# driver = "GPKG", -# delete_layer = TRUE) + # Add the EA_CODE to data + mphc_2018_sf$EA_CODE <- nearest_ids -#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 %>% @@ -186,7 +189,7 @@ summary(mphc_2018_df$hh_gps_accuracy) # ) # #load dataset -# #mphc_2018_sf <- st_read(paste0(output_path, "mphc_2018_sf_ea.gpkg")) +# #mphc_2018_sf <- st_read(file.path(output_path, "mphc_2018_sf_ea.gpkg")) # #convert to dataframe # mphc_2018_df <- mphc_2018_sf %>% @@ -589,27 +592,42 @@ 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)) -#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 %>% @@ -681,7 +699,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 %>% @@ -766,94 +784,106 @@ 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) - -# 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() +zomba_data_path <- file.path(output_path, "zomba_rbind_data.csv") +if (file.exists(zomba_data_path)){ + zomba_data <- read.csv(zomba_data_path) ## FILE MISSING! + + #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() +} 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") ## FILE MISSING! +if (file.exists(malemia_data_path)) { + malemia_data <- read.csv(malemia_data_path) ## FILE MISSING! + + #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() +} else { + print("Malemia data cannot be found. Skipping processing of this for now.") +} ############################################################################ @@ -866,9 +896,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 %>% @@ -896,17 +942,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 %>% @@ -919,7 +967,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/load_required_libraries.R b/load_required_libraries.R index a9edc06..c687ddd 100644 --- a/load_required_libraries.R +++ b/load_required_libraries.R @@ -34,7 +34,8 @@ required_libraries <- c( "caret", # Classification And REgression Training "kableExtra", # for html tables "inlabru", # package for Bayesian spatial modelling - "feather" # reading and writing feather files + "feather", # reading and writing feather files + "nngeo" # nearest neighbour in geospatial ) # Execute code to load (and install) libraries From 066bd840c5f9c094a0476605fe2f22efd693458f Mon Sep 17 00:00:00 2001 From: Baizan Edge Date: Thu, 26 Mar 2026 11:42:37 +0000 Subject: [PATCH 15/31] Changed shapefile from "2018_MPHC_EAs_Final_for_Use_Corrected.shp" to "2018_MPHC_EAs_Final_for_Use.shp" in line with the rest of the code on this branch --- 02_Covariates_Extraction.R | 84 +++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 24 deletions(-) diff --git a/02_Covariates_Extraction.R b/02_Covariates_Extraction.R index 539dbab..39ceb90 100644 --- a/02_Covariates_Extraction.R +++ b/02_Covariates_Extraction.R @@ -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,16 @@ 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))) +# Find duplicate layer names +dup_names <- names(raster_2024_covariates)[duplicated(names(raster_2024_covariates))] + +# Remove layers with duplicate names (keep only the first occurrence) +unique_layers <- !duplicated(names(raster_2024_covariates)) +raster_2024_covariates <- raster_2024_covariates[[unique_layers]] + #Extract rasters using their mean values tic() @@ -97,7 +108,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 +138,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 +190,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 +217,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 +232,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 +262,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 |> From 64d4cb869a64faa3672fc383684b16122eb2905c Mon Sep 17 00:00:00 2001 From: Amanda Baizan Edge Date: Thu, 26 Mar 2026 12:29:42 +0000 Subject: [PATCH 16/31] Added correct file name for shapefile --- 03_HH_Model_Workflow_2024c.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/03_HH_Model_Workflow_2024c.R b/03_HH_Model_Workflow_2024c.R index 39bdccf..7722cc0 100644 --- a/03_HH_Model_Workflow_2024c.R +++ b/03_HH_Model_Workflow_2024c.R @@ -25,7 +25,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 %>% From b7128d4d8f13e62e9ae3e171949d129e0cfbce7a Mon Sep 17 00:00:00 2001 From: Amanda Baizan Edge Date: Thu, 26 Mar 2026 12:30:13 +0000 Subject: [PATCH 17/31] Changed readme to be more useful --- README.md | 79 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index e43313e..832c3f5 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,60 @@ -# 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 +This project requires R and the following R packages: -The main goal of this project is to **model household count** and **population** for census preparation in Malawi +- tidyverse +- sf +- tictoc +- terra +- exactextractr +- haven +- nngeo +- INLA +- gstat +- spdep +- car +- caret +- kableExtra +- inlabru +- feather +- raster ---- +To install all required packages, run this in your R console: -## 🔄 Processing Flow +``` r +install.packages(c("tidyverse", "sf", "tictoc", "terra", "exactextractr", "haven", "nngeo", "INLA", "gstat", "spdep", "car", "caret", "kableExtra", "inlabru", "feather", "raster")) +``` -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`)** +## Data Pre-processing ---- +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. -## 🛠️ Requirements +Run the following scripts in order for a typical workflow: -Make sure the following R packages are installed: +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 - caveat "missing files" +7. `04_Rasterize.R` - not used in modelling and not run +8. `02_Covariates_Extraction.R` - successfully run - with caveat modified to work without data created in `04_Rasterize.R` + +## Modelling scripts +In progress - see [Model code review of the project wiki](https://github.com/datasciencecampus/WorldPop-Malawi-fork/wiki/Model-code-review) + + +## Additional Resources + +- [Full Project Wiki](https://github.com/datasciencecampus/WorldPop-Malawi-fork/wiki) -```r -install.packages(c("tidyverse", "sf", "terra", "raster", "exactextractr")) From 3cd0fa911d5d6d3ecfe16b28a5e9f8c356e1f4c8 Mon Sep 17 00:00:00 2001 From: Amanda Baizan Edge Date: Tue, 21 Apr 2026 11:24:00 +0100 Subject: [PATCH 18/31] extra package needed to run HH modelling --- 03_HH_Model_Workflow_2024c.R | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/03_HH_Model_Workflow_2024c.R b/03_HH_Model_Workflow_2024c.R index 7722cc0..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 @@ -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? From c2b7b51bf66a54f0438f97b5c0d5ae6bcdbdd71c Mon Sep 17 00:00:00 2001 From: Amanda Baizan Edge Date: Tue, 21 Apr 2026 11:24:21 +0100 Subject: [PATCH 19/31] Improved readme --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 832c3f5..1d282c9 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Before running the main scripts, data pre-processing steps are required. Please Run the following scripts in order for a typical workflow: -1. `01_Raster_Mosaicking_Buildings_2018.R` - successfully run +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 @@ -51,10 +51,11 @@ Run the following scripts in order for a typical workflow: 8. `02_Covariates_Extraction.R` - successfully run - with caveat modified to work without data created in `04_Rasterize.R` ## Modelling scripts + In progress - see [Model code review of the project wiki](https://github.com/datasciencecampus/WorldPop-Malawi-fork/wiki/Model-code-review) +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) - From 0bbbb7b242bcfdb575583f392efc69b10c4bf950 Mon Sep 17 00:00:00 2001 From: TSGreen Date: Tue, 21 Apr 2026 15:08:51 +0100 Subject: [PATCH 20/31] refactor: Update names of covars in rast object to match file naming --- 02_Covariates_Extraction.R | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/02_Covariates_Extraction.R b/02_Covariates_Extraction.R index 39ceb90..5fae453 100644 --- a/02_Covariates_Extraction.R +++ b/02_Covariates_Extraction.R @@ -90,12 +90,10 @@ raster_list #Stack all unique covariates raster_2024_covariates <- rast(paste0(covs_path_2024, c(raster_list))) -# Find duplicate layer names -dup_names <- names(raster_2024_covariates)[duplicated(names(raster_2024_covariates))] +names(raster_2024_covariates) <- sources(raster_2024_covariates) %>% + lapply(str_split_i, "/", -1) %>% + lapply(str_split_i, ".tif", 1) -# Remove layers with duplicate names (keep only the first occurrence) -unique_layers <- !duplicated(names(raster_2024_covariates)) -raster_2024_covariates <- raster_2024_covariates[[unique_layers]] #Extract rasters using their mean values tic() From 9e65e7c8962decd16f1fe584d34fee6d95132ee3 Mon Sep 17 00:00:00 2001 From: Amanda Baizan Edge Date: Mon, 4 May 2026 10:17:23 +0100 Subject: [PATCH 21/31] Added "glmnet" as one of the packages to install --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1d282c9..ed11571 100644 --- a/README.md +++ b/README.md @@ -28,11 +28,12 @@ This project requires R and the following R packages: - inlabru - feather - raster +- glmnet To install all required packages, run this in your R console: ``` r -install.packages(c("tidyverse", "sf", "tictoc", "terra", "exactextractr", "haven", "nngeo", "INLA", "gstat", "spdep", "car", "caret", "kableExtra", "inlabru", "feather", "raster")) +install.packages(c("tidyverse", "sf", "tictoc", "terra", "exactextractr", "haven", "nngeo", "INLA", "gstat", "spdep", "car", "caret", "kableExtra", "inlabru", "feather", "raster", "glmnet")) ``` ## Data Pre-processing From ae7b4456208efc66cff4ba71128b910ce1716a53 Mon Sep 17 00:00:00 2001 From: Amanda Baizan Edge Date: Mon, 4 May 2026 13:54:12 +0100 Subject: [PATCH 22/31] zomba data processing function in utils and added processing step to 00_Data_Processing2 script Co-authored-by: Copilot --- 00_Data_Processing2.R | 11 ++++++- utils.R | 67 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/00_Data_Processing2.R b/00_Data_Processing2.R index d7b5aa5..dccf666 100644 --- a/00_Data_Processing2.R +++ b/00_Data_Processing2.R @@ -784,9 +784,16 @@ dhs_hh_size<- dhs_centroids_sf %>% #################################################################################### ######### PROCESS ZOMBA DISTRICT DATA ################################################ +# 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") +) + zomba_data_path <- file.path(output_path, "zomba_rbind_data.csv") + if (file.exists(zomba_data_path)){ - zomba_data <- read.csv(zomba_data_path) ## FILE MISSING! + zomba_data <- read.csv(zomba_data_path) #Add a new column to data called hh_count zomba_data <- zomba_data %>% @@ -828,6 +835,8 @@ if (file.exists(zomba_data_path)){ 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.") } diff --git a/utils.R b/utils.R index 18fb336..d55cbf6 100644 --- a/utils.R +++ b/utils.R @@ -14,3 +14,70 @@ generate_buffered_country_boundary <- function( 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() +} From 8a3a37f69618a56d87b7f7fdbd1bd2e86067f803 Mon Sep 17 00:00:00 2001 From: Amanda Baizan Edge Date: Mon, 4 May 2026 13:55:01 +0100 Subject: [PATCH 23/31] Added message to say that malemia data is available --- 00_Data_Processing2.R | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/00_Data_Processing2.R b/00_Data_Processing2.R index dccf666..34d2808 100644 --- a/00_Data_Processing2.R +++ b/00_Data_Processing2.R @@ -9,6 +9,8 @@ library(haven) library(tidyverse) #library(foreign) +source("utils.R") + options(scipen = 999) # turn off scientific notation for all variables #Specify Drive Path @@ -845,10 +847,10 @@ if (file.exists(zomba_data_path)){ #################################################################################### ######### PROCESS MALEMA DISTRICT DATA ################################################ -malemia_data_path <- file.path(input_path, "malemia_hh_without_IDs.csv") ## FILE MISSING! +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) ## FILE MISSING! + malemia_data <- read.csv(malemia_data_path) #Add a new column to data called hh_count malemia_data <- malemia_data %>% @@ -890,6 +892,7 @@ if (file.exists(malemia_data_path)) { 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.") } From 1ea5407c58f09f479d1c5a3e19be29e9a6e6a005 Mon Sep 17 00:00:00 2001 From: Amanda Baizan Edge Date: Mon, 4 May 2026 14:01:02 +0100 Subject: [PATCH 24/31] Updated readme to remove "missing files" flag --- README.md | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/README.md b/README.md index ed11571..77f4a8a 100644 --- a/README.md +++ b/README.md @@ -10,26 +10,6 @@ This is the `ons-compatability-updates` branch, which includes updates for compa ## Dependencies -This project requires R and the following R packages: - -- tidyverse -- sf -- tictoc -- terra -- exactextractr -- haven -- nngeo -- INLA -- gstat -- spdep -- car -- caret -- kableExtra -- inlabru -- feather -- raster -- glmnet - To install all required packages, run this in your R console: ``` r @@ -47,7 +27,7 @@ Run the following scripts in order for a typical workflow: 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 - caveat "missing files" +6. `00_Data_Processing2.R` - successfully run 7. `04_Rasterize.R` - not used in modelling and not run 8. `02_Covariates_Extraction.R` - successfully run - with caveat modified to work without data created in `04_Rasterize.R` From adbd1d0b5afb8cf86c7544f26862e6711274169b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fu=C5=9F=20=C3=96ks=C3=BCz?= Date: Mon, 11 May 2026 12:33:58 +0100 Subject: [PATCH 25/31] Standardize household identifier and row-bind all TA CSVs into a single Zomba dataset --- data_merge_zomba.R | 97 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 data_merge_zomba.R diff --git a/data_merge_zomba.R b/data_merge_zomba.R new file mode 100644 index 0000000..ae8b0eb --- /dev/null +++ b/data_merge_zomba.R @@ -0,0 +1,97 @@ +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) +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, + 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 +) + From 153917c2bb92adefd645832faf3f2c7c86103689 Mon Sep 17 00:00:00 2001 From: Amanda Baizan Edge Date: Thu, 21 May 2026 14:43:34 +0100 Subject: [PATCH 26/31] change the generate buffered country boundry function in utils to have a variable called buffer --- utils.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils.R b/utils.R index d55cbf6..8f9f77b 100644 --- a/utils.R +++ b/utils.R @@ -2,7 +2,8 @@ library(sf) generate_buffered_country_boundary <- function( shape_path, - file_name = "Country_Shapefile_Buffer_10km.shp" + file_name, + buffer ){ #' Produce buffered country boundary shapefile by dissolving EA geometries and #' adding 10km buffer @@ -10,7 +11,7 @@ generate_buffered_country_boundary <- function( ea_geoms <- st_read(file.path(shape_path, "2018_MPHC_EAs_Final_for_Use.shp")) country_buffer <- ea_geoms %>% st_union() %>% - st_buffer(10E3) + st_buffer(buffer) st_write(country_buffer, file.path(shape_path, file_name)) return(country_buffer) } From 51a3305b6f16b1c6a0a8f1b3204f335134aded0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fu=C5=9F=20=C3=96ks=C3=BCz?= Date: Fri, 5 Jun 2026 11:36:55 +0100 Subject: [PATCH 27/31] updated zomba data merge --- data_merge_zomba.R | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/data_merge_zomba.R b/data_merge_zomba.R index ae8b0eb..ede6bb6 100644 --- a/data_merge_zomba.R +++ b/data_merge_zomba.R @@ -34,8 +34,6 @@ glimpse(Ntholowa) Malemia_hh <- read_csv("malemia_hh_without_IDs.csv") #standardize column labels - - standardise_names <- function(df) { df %>% rename_with(~ "household_number", @@ -51,6 +49,7 @@ 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) @@ -61,7 +60,6 @@ Ntholowa <- standardise_names(Ntholowa) colnames(Chikowi) #Merge files - zomba_rbind_data <- bind_rows( Chikowi, chimbalanga, @@ -70,6 +68,7 @@ zomba_rbind_data <- bind_rows( Malemia, Mbiza, Mkumbira, + Mwambo, Mlumbe, Mwembere, Ngwelero, From 18ee4a11270a4a870fab9f3adb63f533cd4259d6 Mon Sep 17 00:00:00 2001 From: Amanda Baizan Edge Date: Wed, 10 Jun 2026 15:32:19 +0100 Subject: [PATCH 28/31] Spacified 10km buffer in raster mosaicking scripts --- 01_Raster_Mosaicking_Buildings_2018.R | 2 +- 01_Raster_Mosaicking_Buildings_2024.R | 2 +- 01_Raster_Mosaicking_Workflow_2018.R | 2 +- 01_Raster_Mosaicking_Workflow_2024.R | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/01_Raster_Mosaicking_Buildings_2018.R b/01_Raster_Mosaicking_Buildings_2018.R index 733b75a..47f2828 100644 --- a/01_Raster_Mosaicking_Buildings_2018.R +++ b/01_Raster_Mosaicking_Buildings_2018.R @@ -18,7 +18,7 @@ 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(shp_path, boundary_data_filename) + 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")) diff --git a/01_Raster_Mosaicking_Buildings_2024.R b/01_Raster_Mosaicking_Buildings_2024.R index d810846..36a07ff 100644 --- a/01_Raster_Mosaicking_Buildings_2024.R +++ b/01_Raster_Mosaicking_Buildings_2024.R @@ -16,7 +16,7 @@ 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(shp_path, boundary_data_filename) + 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")) diff --git a/01_Raster_Mosaicking_Workflow_2018.R b/01_Raster_Mosaicking_Workflow_2018.R index 4362ab7..9225eb9 100644 --- a/01_Raster_Mosaicking_Workflow_2018.R +++ b/01_Raster_Mosaicking_Workflow_2018.R @@ -16,7 +16,7 @@ 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(shp_path, boundary_data_filename) + 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")) diff --git a/01_Raster_Mosaicking_Workflow_2024.R b/01_Raster_Mosaicking_Workflow_2024.R index e798833..6576b85 100644 --- a/01_Raster_Mosaicking_Workflow_2024.R +++ b/01_Raster_Mosaicking_Workflow_2024.R @@ -16,7 +16,7 @@ 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(shp_path, boundary_data_filename) + 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")) From a31c9f1db5d4e051a9bb76e3c68e43a7e1de21e8 Mon Sep 17 00:00:00 2001 From: Amanda Baizan Edge Date: Wed, 10 Jun 2026 16:40:27 +0100 Subject: [PATCH 29/31] Added country file with no buffer to rasterize.R script --- 04_Rasterize.R | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/04_Rasterize.R b/04_Rasterize.R index 4bf0673..310f9d9 100644 --- a/04_Rasterize.R +++ b/04_Rasterize.R @@ -16,7 +16,6 @@ bcount_path_2024 <- paste0(drive_path, "Input_Data/Mosaic_Buildings_2024/") #Load datasets 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,10 +44,25 @@ hh_size <- hh_size |> hh_ea <-full_join(ea, hh_size, by = "EA_CODE") # Rasterize Country ------------------------------------------------------ +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) +} country <- st_transform(country, crs = st_crs(bcount)) -country_raster <- rasterize(country, bcount, field = "Country_ID") +# Convert to sf object, set original CRS (same as EA data), then transform +country <- st_as_sf(country) %>% + st_set_crs(st_crs(ea)) %>% # Set to EA's original CRS + st_transform(crs = st_crs(bcount)) %>% # Transform to WGS84 + st_make_valid() %>% # Fix invalid geometry + mutate(Country_ID = 1) + +country_raster <- terra::rasterize(country, bcount, field = "Country_ID") plot(country_raster) #stack rasters From 921219ae9c2fe0a5224089b20fd5e698d4190c1a Mon Sep 17 00:00:00 2001 From: Amanda Baizan Edge Date: Wed, 10 Jun 2026 16:41:28 +0100 Subject: [PATCH 30/31] Added documentation on new data and running --- 00_Data_Processing2.R | 3 ++- README.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/00_Data_Processing2.R b/00_Data_Processing2.R index 34d2808..67b2b20 100644 --- a/00_Data_Processing2.R +++ b/00_Data_Processing2.R @@ -594,7 +594,8 @@ sum(Naca_data$hh_count) ##################################################################################### #################################################################################### ######### PROCESS DHS Listing DATA ################################################ - +# 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 dhs_file_path <- file.path(input_path, "DHS_Segmented_File.csv") if (!file.exists(dhs_file_path)) { diff --git a/README.md b/README.md index 77f4a8a..b1cdfab 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Run the following scripts in order for a typical workflow: 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` - not used in modelling and not 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` ## Modelling scripts From 7bb5a42a4b12f1180e0aed1cb917be2864a83d8b Mon Sep 17 00:00:00 2001 From: Amanda Baizan Edge Date: Wed, 17 Jun 2026 12:05:32 +0100 Subject: [PATCH 31/31] Found an issue between loading the country file and creating it - which was creating NAs by forcing CRS change which was not needed. Changed the colours to make the plot more visible. --- 04_Rasterize.R | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/04_Rasterize.R b/04_Rasterize.R index 310f9d9..0384057 100644 --- a/04_Rasterize.R +++ b/04_Rasterize.R @@ -53,17 +53,27 @@ if(file.exists(file.path(shapefile_path, country_data_filename))) { buffer = 0) } -country <- st_transform(country, crs = st_crs(bcount)) +# 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)) +} -# Convert to sf object, set original CRS (same as EA data), then transform -country <- st_as_sf(country) %>% - st_set_crs(st_crs(ea)) %>% # Set to EA's original CRS - st_transform(crs = st_crs(bcount)) %>% # Transform to WGS84 - st_make_valid() %>% # Fix invalid geometry - mutate(Country_ID = 1) +country <- country %>% + st_transform(crs = st_crs(bcount)) %>% + st_make_valid() %>% + mutate(Country_ID = 1L) -country_raster <- terra::rasterize(country, bcount, field = "Country_ID") -plot(country_raster) +# 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)