This repository documents the analytical workflow behind the reported results for the Las Bambas case study. The project is organized so that the notebooks read inputs from Data/, write reproducible outputs to Results/, and reuse shared Python utilities stored in src/.
.
|-- Code/
| |-- Cluster_AssociationRules.ipynb <--- Script that reproduces the exploratory analysis
| `-- Spatial_Analysis.ipynb <--- Script that reproduces the polygon construction and Mapbiomas analysis
|-- src/
| `-- las_bambas_analysis/
| |-- cluster_plots.py
| |-- paths.py
| |-- spatial_figures.py
| |-- spatial_geometry.py
| `-- water.py
|-- Data/
| |-- Conflicto_bambas.csv
| |-- ReporteFechaxConflicto_bambas.csv
| |-- geometriasxcasoxminabambas.gpkg
| `-- Área en Operación Minera.geojson
|-- CITATION.cff
|-- environment.yml
|-- environment-lock.yml
|-- pyproject.toml
|-- requirements.txt
|-- requirements-lock.txt
`-- Results/
|-- cluster_association_rules/
`-- spatial_analysis/
The original source file names were preserved to maintain provenance and avoid breaking links to the underlying materials.
Conflicto_bambas.csv: base conflict matrix by group. It includes identifiers (Grupo,GrupoID), case metadata, and the binary thematic variables used for clustering and association rules.ReporteFechaxConflicto_bambas.csv: time series of reports byGrupoIDandFechaReporte, including conflict status and descriptive fields from the monthly monitoring process.geometriasxcasoxminabambas.gpkg: main geopackage used in the spatial analysis. The notebook reads theCarretera,Mina,Puente,Rio_Quebrada, andCentros_Pobladoslayers.Área en Operación Minera.geojson: mining operation polygons used as an additional spatial reference for land-cover and water analyses.
The repository includes a lightweight Python package in src/las_bambas_analysis/ to keep the notebooks shorter and easier to audit.
paths.py: repository-root discovery and centralized output-path creation.cluster_plots.py: paper-style temporal and spatial cluster plotting helpers.spatial_geometry.py: buffer generation and yearly conflict-area construction.spatial_figures.py: minimalist polygon-map export helper.water.py: MapBiomas Agua tile download and yearly water-area statistics.
This notebook reconstructs the spatial and environmental trajectory of the Las Bambas case. Its sections follow the notebook headings:
Yearly Polygon Construction: builds yearly conflict/influence polygons from the geopackage and the temporal report file.Dynamic Visualization of Map Evolution: prepares a time-enabled visualization of the conflict polygon.Figures > Map Evolution: exports yearly maps of the polygon and associated spatial features.Figures > Link to Number of Population Centers: relates influence area, active conflicts, and affected population centers.MapBiomas > Land Cover: extracts and plots land-cover classes for selected reference years.MapBiomas > Figure: Map by Period: exports land-cover maps for key years.MapBiomas > Transitions: summarizes year-to-year land-cover change and exports a transition dynamics figure.Water: downloads thematic layers, computes natural and mining-related water area, and exports comparison figures.
Inputs used:
Data/geometriasxcasoxminabambas.gpkgData/ReporteFechaxConflicto_bambas.csvData/Área en Operación Minera.geojson
Main outputs in Results/spatial_analysis/:
maps/poligono_anual_bambas/figures/land_cover/maps/land_cover_clases_journal/figures/transiciones/figures/agua/intermediate/serie_temporal_poligonos.geojsonintermediate/agua_tiles_out/
Shared helpers imported from src/las_bambas_analysis/:
paths.pyspatial_geometry.pyspatial_figures.pywater.py
This notebook covers the typological and temporal components of the conflict:
File Inputs: loads the conflict matrix and the temporal report file.Clusters > Method Comparison: compares clustering techniques using Jaccard distance.Final Hierarchical Cluster: defines the final clustering solution used for substantive interpretation.Temporal Visualization: builds the yearly time series of conflicts by cluster.Spatial Map: links clusters to population centers and exports maps by period.FP-Growth: identifies frequent itemsets and association rules among conflict types.
Inputs used:
Data/Conflicto_bambas.csvData/ReporteFechaxConflicto_bambas.csvData/geometriasxcasoxminabambas.gpkg
Main outputs in Results/cluster_association_rules/:
figures/cluster_time.pdffigures/cluster_time.pngmaps/clusters_temporales/
Shared helpers imported from src/las_bambas_analysis/:
paths.pycluster_plots.py
The repository provides four dependency files with different purposes:
environment.yml: recommended setup file. It captures the curated environment that was validated for this repository.environment-lock.yml: exactconda env export --no-buildssnapshot of the validated environment.requirements.txt: exactpipdependency list matching the validated environment.requirements-lock.txt: rawpip freezesnapshot from the validated environment, kept only for audit and traceability.
Recommended setup:
conda env create -f environment.ymlconda activate las-bambas-analysis
Optional secondary route:
- Create or activate your own Python environment.
pip install -r requirements.txt
Then:
- Open the notebooks in
Code/. - Run the cells in order.
- Both notebooks automatically detect the project root, import reusable helpers from
src/, read inputs fromData/, and write outputs insideResults/.
Notes:
- The MapBiomas sections require prior Google Earth Engine authentication.
- Validated baseline:
Python 3.11,NumPy 2.4.3, andpandas 2.3.3. - The geospatial stack (
GDAL,GeoPandas,Fiona,Rasterio,Shapely) is the most fragile part of the setup on Windows, so the curatedenvironment.ymlis the recommended installation path. - The curated
environment.ymlkeeps the compiled geospatial stack incondaand installs the remaining scientific and Earth Engine packages throughpipinside the same environment because that combination proved more reliable than a single-step solver attempt. - The
pip install -r requirements.txtroute is best treated as a secondary option for environments that can already resolve the compiled geospatial dependencies cleanly. environment-lock.ymlandrequirements-lock.txtare archival snapshots of the validated environment. They are useful for audit and traceability, but they are more verbose and less portable than the curated files.requirements-lock.txtis not intended as the primary installation file becausepip freezemay contain local build references from the validating machine.- Avoid running
pip install ...inside the notebooks, because that can desynchronize compiled dependencies already installed in the active kernel. - Both
environment.ymlandrequirements.txtinstall the local package in editable mode (-e .) so the notebooks can reuse the shared modules. - Outputs are written inside
Results/so the project does not depend on external Colab-style paths.
The repository includes a CITATION.cff file with the metadata of the associated study so citation information is available in a standard format for archival or public release.