Jupyter Notebook for threshold detection and ecological zoning using the Priority Index framework
收藏资源简介:
This repository contains the comprehensive Python source code and analytical framework developed for the study "A nonlinear threshold-based study on ecological zoning for water conservation in Guangdong Province, China". It provides a reproducible pipeline that integrates spatial analysis with advanced machine learning to delineate environmental management zones and interpret the non-linear drivers of water conversation.Methodological Workflow: The codebase is structured around two independent but complementary analytical phases:Spatial Zoning and Priority Index (PI): Processes multi-source environmental and socio-economic variables (e.g., Temperature, Precipitation, DEM, GDP, Population) to compute a spatially-weighted Priority Index. It couples these metrics with Gi* spatial statistics to classify regions into specific ecological management types.Machine Learning and SHAP Interpretation: Utilizes an Optuna-optimized XGBoost model to evaluate the complex, non-linear impacts of the driving factors. It includes extensive SHapley Additive exPlanations (SHAP) analyses to map spatial SHAP distributions, extract zero-SHAP thresholds, and visualize feature interactions.Repository Structure:config.py: Global configurations, dynamic file mappings, and spatial weights.spatial_utils.py: Core geospatial algorithms for raster alignment and PI computation.shap_utils.py: Utilities for SHAP calculation, polynomial fitting for thresholds, and spatial visualization.main_zoning.py: Execution script for the spatial zoning workflow.main_xgboost.py: Execution script for model training and SHAP interpretation.Usage Requirements: Researchers looking to reproduce or adapt this framework should place their aligned raster datasets (.tif), spatial grids (.shp), and tabular data (.csv) into the designated local ./data/inputs/ directory. For detailed setup instructions and dependencies, please refer to the included README.md file.
本仓库包含为学术研究《中国广东省水源涵养生态分区的非线性阈值研究》开发的完整Python源代码与分析框架。该框架提供了可复现的工作流,整合空间分析与先进机器学习技术,用于划定环境管理分区并解析水源涵养的非线性驱动因素。 方法学工作流:代码库围绕两个独立且互补的分析阶段构建: 1. 空间分区与优先级指数(Priority Index, PI):处理多源环境与社会经济变量(如气温、降水、数字高程模型(Digital Elevation Model, DEM)、国内生产总值(Gross Domestic Product, GDP)、人口),以计算空间加权优先级指数。该模块将上述指标与Gi*空间统计方法相结合,将区域划分为特定的生态管理类型。 2. 机器学习与SHAP解释:采用经Optuna优化的极限梯度提升(Extreme Gradient Boosting, XGBoost)模型,评估驱动因子的复杂非线性影响。其中包含大量Shapley可加解释(SHapley Additive exPlanations, SHAP)分析,用于绘制空间SHAP分布、提取零SHAP阈值,并可视化特征交互作用。 仓库文件结构: config.py:全局配置、动态文件映射与空间权重设置。 spatial_utils.py:用于栅格对齐与优先级指数计算的核心地理空间算法工具。 shap_utils.py:用于SHAP计算、阈值多项式拟合与空间可视化的工具函数。 main_zoning.py:空间分区工作流的执行脚本。 main_xgboost.py:模型训练与SHAP解释的执行脚本。 使用要求:欲复现或适配本框架的研究人员,需将已对齐的栅格数据集(.tif格式)、空间矢量网格数据(.shp格式)与表格数据(.csv格式)放入指定的本地./data/inputs/目录中。有关详细的安装说明与依赖项,请参阅附带的README.md文件。



