Sierra Minera Soil Dataset
June 16, 2026 · View on GitHub
This repository contains a reproducible method in R to integrate heterogeneous soil geochemistry datasets from the Sierra Minera mining district (Cartagena–La Unión, SE Spain) and generate multi-element soil maps (Pb, Zn, As, Cd).
The code reorganizes raw laboratory spreadsheets into a spatial master table and uses that harmonized dataset to produce both exploratory and interpolated maps.
The raw datasets are archived in Zenodo, while this repository provides the reproducible scripts required to generate the maps in R.
Table of Contents
- Overview
- Context
- Reproducible Method
- Scripts
- Results
- 3D Terrain Visualization
- Interactive Map
- Data Availability
- Data Sources
- Repository Structure
- Status
Overview
The purpose of this repository is to provide a reproducible method to generate multi-element soil maps for the Sierra Minera from heterogeneous geochemical datasets.
The method consists of three main steps:
- Load heterogeneous Excel datasets
- Harmonize sample identifiers and UTM coordinates
- Generate multi-element maps in R from the harmonized spatial dataset
The resulting workflow enables reproducible spatial analysis and visualization of trace elements in soils.
Context
The datasets originate from soil geochemistry studies conducted in the Sierra Minera mining district.
The datasets used in this repository originate from soil geochemistry studies conducted by José Matías Peñas Castejón and collaborators in the Sierra Minera mining district (Cartagena–La Unión, SE Spain).
This repository reorganizes these heterogeneous sources into a reproducible spatial dataset suitable for open scientific analysis and cartographic visualization in R.
Reproducible Method
Multi-element Mapping Workflow
The method implemented in this repository follows this logic:
Raw Excel datasets
↓
Harmonization of sample IDs and UTM coordinates
↓
Construction of a master spatial table
↓
Extraction of total soil element concentrations (Pb, Zn, As, Cd)
↓
Interactive mapping in R (Leaflet)
↓
IDW interpolation and raster visualization with hillshade
3D Terrain Visualization Workflow
The repository also includes an experimental 3D visualization workflow:
Master spatial table + total element concentrations
↓
Integration of elevation data (DEM)
↓
Integration of official drainage network (CNIG)
↓
3D terrain visualization (rayshader)
The raw data can be downloaded from Zenodo and placed in a local folder such as raw_data/.
Once configured, the scripts allow the user to reproduce all maps directly in R.
Scripts
The reproducible code is located in the R/ directory.
The repository uses a thematic script classification system. Script codes indicate the role of each workflow component rather than execution order.
For additional details, see:
R/0_build_samples_master.R
Builds the harmonized spatial master table from heterogeneous spreadsheets.
Main tasks:
- load multiple Excel files
- normalize field sample identifiers
- extract UTM coordinates
- review duplicated coordinate records
- construct a master spatial table
R/2_build_geo_total_elements_wide.R
Combines spatial and geochemical information into a single georeferenced dataset.
Main tasks:
- load or generate the master sample table
- retrieve elevation values from a Digital Elevation Model (DEM)
- join coordinates and elevation data
- integrate total element concentrations
- generate a unified geospatial geochemistry table
R/1_map_total_elements_leaflet.R
Creates an interactive Leaflet map of total soil element concentrations (Pb, Zn, As, Cd).
Main tasks:
- visualize sampling locations
- display multiple soil elements
- generate interactive map layers
- provide dynamic element selection
R/1_leaflet_idw_total_elements_map.R
Generates interpolated multi-element surfaces using Inverse Distance Weighting (IDW) and overlays them on a DEM-derived hillshade.
Main tasks:
- interpolate element concentrations
- generate raster surfaces
- overlay terrain relief (hillshade)
- visualize multi-layer outputs interactively
R/1_map_pb_terrain_3d.R
Creates an experimental 3D terrain visualization of the Sierra Minera using a Digital Elevation Model (DEM), Pb concentrations and the official drainage network.
Main tasks:
- generate a reduced DEM for 3D rendering
- visualize Pb concentrations in three dimensions
- integrate official hydrographic network data
- create interactive terrain visualizations with rayshader
- export PNG and HTML outputs
Results
Example outputs generated by the reproducible code.
Sampling points and element concentrations

Interpolated raster surface (example: Pb)

3D Terrain Visualization
⚠️ Work in progress
The 3D visualization workflow is currently under active development and should be considered a first proof-of-concept rather than a final analytical product.
The objective is to integrate:
- Digital Elevation Models (DEM)
- Harmonized soil geochemistry datasets
- Pb sampling locations
- Official drainage network
- Future interpolated contamination surfaces
The current prototype combines terrain elevation, Pb concentrations and the official hydrographic network to explore potential relationships between topography, drainage pathways and contaminant distribution.
Example output

Interactive Viewer
Data sources
The drainage network used in the 3D visualization was obtained from the Spanish National Centre for Geographic Information (CNIG) hydrography dataset:
https://centrodedescargas.cnig.es/CentroDescargas/hidrografia
Future versions of the workflow may incorporate:
- multi-element 3D visualization
- interpolated contamination surfaces
- surface runoff modelling
- watershed analysis
- human exposure and environmental risk layers
Interactive Map
An interactive multi-element map (IDW + hillshade) is available online:
This map allows exploration of:
- multiple soil elements (Pb, Zn, As, Cd)
- interpolated surfaces
- sampling point data
- terrain context
Data Availability
The raw soil geochemistry datasets used in this repository are archived in Zenodo:
https://doi.org/10.5281/zenodo.18940847
This repository does not duplicate the archived raw dataset. Instead, it provides the reproducible R workflow required to integrate and analyze the data.
A harmonized geospatial dataset generated from the original sources is also distributed within this repository for reproducibility purposes:
data/geo_total_elements_wide.csvdata/geo_total_elements_wide.rds
Data Sources
The workflow integrates heterogeneous laboratory datasets associated with soil geochemistry studies in the Sierra Minera mining district.
The geochemical data derive from research carried out by José Matías Peñas Castejón and collaborators. Additional spatial layers may incorporate official geospatial products from the Spanish National Centre for Geographic Information (CNIG).
CNIG Hydrography Download Centre:
https://centrodedescargas.cnig.es/CentroDescargas/hidrografia
The code does not modify the original datasets. Instead, it harmonizes and integrates them into a reproducible spatial workflow.
Repository Structure
The repository uses a thematic script classification system. Script codes indicate their role within the workflow rather than execution order.
For a detailed description of the coding scheme, see:
.
├── README.md
├── SCRIPT_CODES.md
├── LICENSE
├── data/
│ ├── geo_total_elements_wide.csv
│ └── geo_total_elements_wide.rds
├── R/
│ ├── 0_build_samples_master.R
│ ├── 1_leaflet_idw_total_elements_map.R
│ ├── 1_map_pb_terrain_3d.R
│ ├── 1_map_total_elements_leaflet.R
│ └── 2_build_geo_total_elements_wide.R
└── figures/
├── pb_terrain_3d.html
├── pb_terrain_3d.png
├── total_elements_idw.png
└── total_elements_leaflet.png
Status
The repository currently provides a reproducible workflow for:
- harmonization of heterogeneous soil geochemistry datasets
- construction of a spatial master table
- integration of elevation data
- interactive multi-element mapping
- IDW interpolation
- exploratory 3D terrain visualization
The project remains under active development.
Future developments may include:
- additional elements
- improved interpolation methods
- 3D contamination surfaces
- hydrological analyses
- statistical analysis of geochemical patterns
- integration with environmental and human exposure frameworks