DOI: 10.5281/zenodo.14998570
title: Data and code from paper: Mapping urban slums and their inequality in sub-Saharan Africa

description: This repository contains the data and code produced for the following paper:

Title: Mapping urban slums and their inequality in sub-Saharan Africa

Contact: Chengxiu Li (C.LI2@unido.org)

The dataset and code consist of main two parts, the first part is geospatial dataset including Morphological and Geospatial features, environment variables, socio-economic variables and slum samples, which used to map slums and estimate population residing in slums in SSA. The second part is to conduct further analysis based on the results from the first part, including accuray asessement, comparing slum population in this study to UN estimation, estimating changes in slum population and wealth inequality based on analyzing DHS dataset. 

1. Mapping slum area and estimating slum populations, estimating wealth index

The first part of code is to map slum area, estimate slum population, and predict wealth index. Slum is mapped based on four indicators including access to improved water and sanitation, living space, and housing conditions. These four indicators are predicted using a combination of remote sensing data,geospatial analysis, machine learning algorithms. There are 79 datasets including Morphological andGeospatial features, environmental variables, socio-economic variables, and slum and nonslum samples. For the detailed process of the dataset, can be found in the paper:  "Mapping urban slums and spatial inequality in sub-Saharan Africa". The dataset and code can be accessed in the following link:

https://code.earthengine.google.com/80294c5d5541056a7fa1e0b152aee679

Above code is Google Earth Engine (GEE) code, below are introduction of GEE and detailed procedures for running the code:

1) Introduction to GEE

Google Earth Engine (GEE) is a cloud-based platform designed for analysing and visualizing large-scale geospatial data, such as satellite imagery. It allows users to access powerful datasets like Landsat, Sentinel, and SRTM, as well as apply advanced geospatial analysis using the platform’s computational infrastructure.

This script enables mapping slum and estimating population living in slum, through the analysis of socio-economic and environmental indicators and predicting wealth index and slum index using various geospatial datasets. The script trains classifiers, processes features, and exports results to Google Drive.

2). Prerequisites

Before running the script, ensure the following:



Google Earth Engine Account: Sign up for a Google Earth Engine (GEE) account at https://earthengine.google.com/.

Permissions: Ensure you have access to the required 79 datasets, the access is publicly shared and should be accessible when setting up the account properly

Verify that you have permission to import and export data to/from Google Drive.


3). Step-by-Step Guidance



Step 1: Open Google Earth Engine Code Editor: Navigate to Google Earth Engine Code Editor, sign in with your Google Earth Engine account.

Step 2: Open the code link: https://code.earthengine.google.com/20f2f80950dade78193a9499f8ae8d59

Step 3: Run the Script: Once opening the code, click the Run button. The script will load the datasets, process features, train classifiers, and generate results.

Step 4: Visualize Results: After running the script, the layers will appear in the Layers panel on the right side of the map. Each layer corresponds to a result from the analysis;  View and Adjust Layers: Click on the layer name to toggle its visibility on or off. To adjust its appearance, click the Settings icon next to the layer (e.g., change colors or transparency); Zoom and Pan: Use the zoom buttons in the corner of the map to zoom in or out. To explore different areas, click and drag to pan around the map; Inspect Values: Click on specific areas of the map to view detailed information for that location, including the values of the analyzed results.  Switch Base Map: Change the map style (e.g., from satellite to terrain view) by using the Map options in the top-right corner of the map.

Step 5: Export Results: After running the GEE script, you can export the results directly from the Tasks panel located on the right side of the GEE Code Editor. Locate the Tasks Panel: On the right side of the GEE Code Editor, the Tasks panel will appear once the export command has been triggered in the script. The task will be listed under the "Tasks" section and will describe the export (e.g., exporting an image or table to Google Drive). Initiate Export: To start the export process, click the Run button next to the export task in the Tasks panel. This will initiate the export to the specified destination (e.g., Google Drive). View Exported Files: After the task completes, the exported file will be available in your Google Drive .


4). TroubleshootingIf you encounter issues during the setup or execution of the script, consider the following:



Check for Dataset Access Issues: Ensure all required datasets are available in your account. If any datasets are restricted or missing, request access to author: gaxiuer@gmail.com

Computational Limits: If the script takes too long or exceeds computational limits, try processing in smaller chunks or reducing the area of analysis.

For further GEE information, using the following resources: •    Google Earth Engine Developer Documentation: https://developers.google.com/earth-engine•    GEE Tutorials: https://developers.google.com/earth-engine/tutorials•    Earth Engine Community Forum: https://developers.google.com/earth-engine/community


2. Slum mapping accuracy assessment, slum population estimation and changes in slum population

The second part is based on the Demographic and Health Surveys (DHS) dataset, as well as exported accuracy assessment table and slum population table generated from the above GEE code. The tables exported GEE is adjusted for its format and country name  in order to link with other table (UN slum population table). In the repository, you will find the following dataset and code:



All01ClusterImgpop_MannualName.csv: this is results table exported from GEE code, which contains slum population estimated by this study based on the three dataset including WorldPop (100m resolution, 2020), Global Human Settlement Layer (GHSL) population surfaces (100m resolution, 2020), and High Resolution Settlement Layer (HRSL) population grids (30m resolution, 2018).

AllImgSlum.csv: The table exported from GEE code, which contains predicted wealth index for the slum samples and nonslum samples, the dataset is used to compare difference in wealth index between slum and nonslum samples.

combined_file_CorrectedHouseMaterialUrbanRural.csv: This table contains four living conditions indicators including access to improved water and sanitation, living space, and housing conditions based on the DHS dataset. This table processed orignal DHS dataset to select correct variables, including only targeting in urban area, deleting null value. The data table is used to estimate slum population lacking access to essential services (improved water, sanitation, adequate housing, or sufficient living space, investigate changes in the mean proportion of urban population classified as slum-dwellers by country from 2005 to 2022; and analyzing changes in wealth inequality for each country quantified using Gini index of the asset-based household wealth index over the same period. The original dataset can be requested in the following link: https://www.dhsprogram.com/

CountryCode.csv: This is the country code used to link the table exported from GEE and data table from DHS

DHSconfusionTableRF.csv: This is confusion matrix table used to estimate slum indicators mapping accuracy exported from GEE.

SSAcountryName.csv: This is the country code used to link the table exported from GEE and data table from DHS

UNslumpPro2020.csv: this table contains slum population estimated by UN-habitat, the original data table can be accessed in the following website: https://data.unhabitat.org/pages/housing-slums-and-informal-settlements

DataProcessing and Figures.R: this is R code to process above dataset and generate main figures in the manuscript.  The code has not been amended for wider use and still contains old working directories, you will need to change these for the scripts to run.