Published 2026 | Version v2
Dataset Open

Data and Replication Code for An expanding human footprint will escalate human-elephant conflict in a Southern African landscape through the end of the century

Description

In this study, we assess the drivers and determinants of human-elephant conflict (HEC) in Namibia using a  dataset that tracks conflict events from 2004-2020 across Namibia’s communal conservancies. We use fixed-effects and random-effects regressions to identify causal relationships of weather, vegetation greenness, population and land cover change on HEC and model these out through the end of the century. Additionally, we employ a maximum entropy (MaxEnt) approach to predict the probability of HEC across northern Namibia and identify the spatial patterns of HEC.

Regression Analysis

This archive contains the code, staged inputs, and staged outputs for a seven-step R workflow analyzing seasonal human–elephant conflict regressions and future projections. The repository is organized as regression/code, regression/input, and regression/output. The code directory contains Scripts 0–6 (0_climate_calcs.R through 6_project_hec_regressions.R); the input directory contains script-specific folders (script0_input to script6_input) with the climate, covariate, shapefile, event, and future-scenario files needed for each step; and the output directory contains archived intermediate and final outputs for Scripts 0–5 (script0_output to script5_output). The pipeline constructs seasonal grid-cell and 50 km buffer climate metrics, assigns each grid cell to its nearest protected-area core area, merges static and annual landscape covariates, aggregates crop-raiding and other conflict outcomes by season and year, estimates fixed-effects and count-model regressions, and generates fixed-effects future projection files used for conservancy-level summaries and plots. Key archived outputs are clim_szn_reg_ready.csv in output/script4_output and future_wet_predict_fe.csv and future_dry_predict_fe.csv in output/script5_output. Script 6 reads these fixed-effects projection files from input/script6_input and produces plot objects in memory; no script6_output folder is included in the current archive.

regression/
├── README.md
├── code/
│   ├── 0_climate_calcs.R
│   ├── 1_comb_full_HEC_grid.R
│   ├── 2_get_nearest_core.R
│   ├── 3_join_core_data.R
│   ├── 4_combine_and_sum_HEC.R
│   ├── 5_hec_exp_fe_regressions.Rmd
│   └── 6_project_hec_regressions.R
├── input/
│   ├── script0_input/
│   ├── script1_input/
│   ├── script2_input/
│   ├── script3_input/
│   ├── script4_input/
│   ├── script5_input/
│   └── script6_input/
└── output/
|   ├── script0_output/
|   ├── script1_output/
|   ├── script2_output/
|   ├── script3_output/
|   ├── script4_output/
|   └── script5_output/

Maxent

All data and code for the MaxEnt modeling of human-elephant conflict (HEC) is organized in the following structure. Data includes shapefiles (.shp), rasters (.tif), CSVs (.csv), and RData files (.rda). The code (`maxent/scripts/`) is organized in Quarto markdown documents (.qmd) that can be run to reproduce the analysis.

maxent/
├── data/
│   ├── inputs/
│   │   ├── background_sampling/
│   │   │   ├── all_namib_cons_grid_mask/                   # Mask (.shp) used for bg sampling
│   │   │   ├── hec_occurrences_p/                          # HEC occurrences (.shp) used for bg sampling
│   │   │   ├── hec_reporting_communal_conservancies_ext/   # Extent (.shp) used for bg sampling
│   │   │   ├── hec_sznyr_ratios_updated/                   # HEC ratios (.csv) used for bg sampling
│   │   │   ├── regression_csv/                             # Regression data (.csv) used for bg sampling
│   │   ├── chen_future_LC/
│   │   │   ├── Chen_LC_percent_cover/
│   │   │   │   ├── ssp126/                                 # Chen LC (% cover) projections under ssp126 (.tif)
│   │   │   │   ├── ssp245/                                 # Chen LC (% cover) projections under ssp245 (.tif)
│   │   │   │   ├── ssp370/                                 # Chen LC (% cover) projections under ssp370 (.tif)
│   │   │   │   ├── ssp585/                                 # Chen LC (% cover) projections under ssp585 (.tif)
│   │   │   ├── Global_PFT_projections/                     # Raw global PFT projections from Chen et al., 2022
│   │   ├── environmental_data_extraction/
│   │   │   ├── distance_rasters/                           # Distance to core areas, rivers, fences, and roads (.tif)
│   │   │   ├── dry_szn/                                    # Dry season pr, tas, EVI, SPEI (.tif)
│   │   │   ├── land_cover/                                 # % built, cropland, grassland, shrub, tree, water (.tif)
│   │   │   ├── pop_density/                                # Population density (.tif)
│   │   │   ├── terrain/                                    # Elevation, slope, aspect (.tif)
│   │   │   ├── wet_szn/                                    # Wet season pr, tas, EVI, SPEI (.tif)
│   │   ├── hec_occurrences/
│   │   │   └── indv_crop_raiding_centroids/                # HEC occurrences (.shp) used for MaxEnt modeling
│   │   ├── prediction_rasters/
│   │   │   ├── baseline_2020_with_spei/
│   │   │   │   ├── dry_szn/                                # 2020 dry season predictor variables (.tif)
│   │   │   │   └── wet_szn/                                # 2020 wet season predictor variables (.tif)
│   │   │   └── future/
│   │   │       ├── dry_szn/
│   │   │       │   ├── 2025/
│   │   │       │   │   ├── ssp126/                         # 2025 dry season, ssp126 predictor variables (.tif)
│   │   │       │   │   ├── ssp245/                         # 2025 dry season, ssp245 predictor variables (.tif)
│   │   │       │   │   ├── ssp370/                         # 2025 dry season, ssp370 predictor variables (.tif)
│   │   │       │   │   └── ssp585/                         # 2025 dry season, ssp585 predictor variables (.tif)
│   │   │       │   ├── 2055/
│   │   │       │   │   ├── ssp126/                         # 2055 dry season, ssp126 predictor variables (.tif)
│   │   │       │   │   ├── ssp245/                         # 2055 dry season, ssp245 predictor variables (.tif)
│   │   │       │   │   ├── ssp370/                         # 2055 dry season, ssp370 predictor variables (.tif)
│   │   │       │   │   └── ssp585/                         # 2055 dry season, ssp585 predictor variables (.tif)
│   │   │       │   └── 2085/
│   │   │       │       ├── ssp126/                         # 2085 dry season, ssp126 predictor variables (.tif)
│   │   │       │       ├── ssp245/                         # 2085 dry season, ssp245 predictor variables (.tif)
│   │   │       │       ├── ssp370/                         # 2085 dry season, ssp370 predictor variables (.tif)
│   │   │       │       └── ssp585/                         # 2085 dry season, ssp585 predictor variables (.tif)
│   │   │       └── wet_szn/
│   │   │           ├── 2025/
│   │   │           │   ├── ssp126/                         # 2025 wet season, ssp126 predictor variables (.tif)
│   │   │           │   ├── ssp245/                         # 2025 wet season, ssp245 predictor variables (.tif)
│   │   │           │   ├── ssp370/                         # 2025 wet season, ssp370 predictor variables (.tif)
│   │   │           │   └── ssp585/                         # 2025 wet season, ssp585 predictor variables (.tif)
│   │   │           ├── 2055/
│   │   │           │   ├── ssp126/                         # 2055 wet season, ssp126 predictor variables (.tif)
│   │   │           │   ├── ssp245/                         # 2055 wet season, ssp245 predictor variables (.tif)
│   │   │           │   ├── ssp370/                         # 2055 wet season, ssp370 predictor variables (.tif)
│   │   │           │   └── ssp585/                         # 2055 wet season, ssp585 predictor variables (.tif)
│   │   │           └── 2085/
│   │   │               ├── ssp126/                         # 2085 wet season, ssp126 predictor variables (.tif)
│   │   │               ├── ssp245/                         # 2085 wet season, ssp245 predictor variables (.tif)
│   │   │               ├── ssp370/                         # 2085 wet season, ssp370 predictor variables (.tif)
│   │   │               └── ssp585/                         # 2085 wet season, ssp585 predictor variables (.tif)
│   ├── intermediate/
│   │   ├── background_points/
│   │   │   ├── bg_points_extracted_crop_maxent             # Bg points (.csv & .shp) w/ env data extracted
│   │   │   └── hec_sznyr_bg_points                         # Bg points (.csv & .shp) w/o env data extracted
│   │   └── extracted_hec_occ_sznyr_crop/
│   │       └── hec_occ_points_extracted_crop_maxent        # HEC occurrences (.csv & .shp) w/ env data extracted
│   ├── outputs/
│   │   ├── ENMevaluation/
│   │   │   ├── dry_szn/
│   │   │   │   └── max_eval_dry_4-23-25.rda                # ENMevaluation object for dry szn CR MaxEnt model
│   │   │   └── wet_szn/
│   │   │       └── max_eval_wet_4-23-25.rda                # ENMevaluation object for wet szn CR MaxEnt model
│   │   ├── maxent_model_objects/
│   │   │   ├── dry_szn/
│   │   │   │   └── maxent_cropConf_dryszn_sdm.rda          # MaxEnt model object for dry szn CR HEC
│   │   │   └── wet_szn/
│   │   │       └── maxent_cropConf_wetszn_sdm.rda          # MaxEnt model object for wet szn CR HEC
│   │   └── maxent_predictions/
│   │       ├── baseline/
│   │       │   ├── dry_szn/                                # Continuous HEC predictions (.tif) in 2020 dry szn
│   │       │   └── wet_szn/                                # Continuous HEC predictions (.tif) in 2020 wet szn
│   │       └── future/
│   │           ├── dry_szn/
│   │           │   └── continuous_predictions/             # Continuous future dry szn predictions (.tif)
│   │           └── wet_szn/
│   │               ├── binary_predictions/                 # Binary future wet szn predictions (.tif)
│   │               ├── continuous_predictions/             # Continuous future wet szn predictions (.tif)
│   │               └── difference_maps/
│   │                   ├── binary/                         # Binary difference maps (.tif): 2025 vs 2055, 2085
│   │                   ├── continuous/                     # Continuous difference maps (.tif): 2025 vs 2055, 2085
│   │                   └── persistent_hotspots/            # Persistent hotspot/coldspot maps (.tif)
├── scripts/
│   ├── 01_maxent_extract_occ_env_data_CR.qmd               # Extract env data to HEC occurrences
│   ├── 02_maxent_generate_bg_points_CR.qmd                 # Generate bg points
│   ├── 03_maxent_extract_bg_env_data_CR.qmd                # Extract env data to bg points
│   ├── 04_maxent_predictions_CR.qmd                        # Model evaluation, run MaxEnt, make predictions
│   ├── 05_maxent_prediction_plotting_CR.qmd                # Plot binary/continuous predictions
│   └── maxent_pred_env_data_prep_CR.qmd                    # Prepare env data for predictions

 

Files

maxent.zip

Files (4.2 GB)

Name Size Download all
md5:058091b76ebe02d265325686680a0e38
2.2 GB Preview Download
md5:2d8aaf27d411d8636af3efe85b7f2af4
2.0 GB Preview Download

Additional details

Software

Programming language
R , RMarkdown