eea-river-proximity / README.md
MartinaAdamuscinova's picture
Add facility_timeseries, per_bin, and events parquet descriptions to README
24cfab1 verified
|
Raw
History Blame Contribute Delete
13.5 kB
---
license: cc-by-4.0
task_categories:
- tabular-classification
- feature-extraction
tags:
- environment
- rivers
- pollution
- geospatial
- europe
size_categories:
- 100K<n<1M
---
# EEA Industrial Emissions - River Proximity Dataset
This dataset links **160,576 industrial facilities** from the European Environment Agency (EEA) to nearby rivers, with **upstream/downstream flow analysis** based on HydroRIVERS network data.
## Why This Dataset?
Industrial facilities that discharge pollutants into water bodies affect downstream ecosystems and communities. This dataset enables:
- **Impact assessment**: Which communities/ecosystems are downstream of polluting facilities?
- **Source tracing**: Where does a facility's water supply come from?
- **Regulatory analysis**: Mapping industrial emissions to affected river networks
- **Environmental research**: Studying relationships between industry and water quality
## How It Works
```
┌─────────────┐
│ UPSTREAM │ ← Source water (green)
│ (5 parts) │ flowing TOWARD facility
└──────┬──────┘
───────●─────── ← Split point (closest to facility)
┌──────┴──────┐
│ FACILITY │ ← Industrial facility (orange)
│ (211m) │ within 1km of river
└─────────────┘
┌──────┴──────┐
│ DOWNSTREAM │ → Affected water (red)
│ (4 parts) │ flowing AWAY from facility
└─────────────┘
```
For each facility:
1. Find the closest river segment within 1km
2. Split the river at the closest point
3. Trace **upstream** 10km (source water)
4. Trace **downstream** 10km (potentially affected)
5. Clip water surface polygons to match
## Dataset Files
### `river_data_facilities.geoparquet` (2.6 GB)
Main dataset with 160,576 facilities matched to rivers.
| Column | Type | Description |
|--------|------|-------------|
| `facilityName` | string | Name of industrial facility |
| `city` | string | City location |
| `countryName` | string | Country |
| `EPRTR_SectorCode` | int | Industry sector code (1-9) |
| `EPRTR_SectorName` | string | Industry sector name |
| `Pollutant` | string | Pollutant released to water |
| `Releases` | float | Amount released |
| `closest_river_id` | int | HydroRIVERS segment ID |
| `distance_to_river_m` | float | Distance to river (meters) |
| `river_strahler` | int | Strahler stream order (1-9) |
| `river_discharge` | float | Average discharge (m³/s) |
| `upstream_segment_ids` | list[int] | Upstream HydroRIVERS IDs |
| `downstream_segment_ids` | list[int] | Downstream HydroRIVERS IDs |
| `n_upstream` | int | Number of upstream parts |
| `n_downstream` | int | Number of downstream parts |
| `upstream_line_wkb` | bytes | Upstream river geometry (WKB) |
| `downstream_line_wkb` | bytes | Downstream river geometry (WKB) |
| `upstream_poly_wkb` | bytes | Upstream water surface (WKB) |
| `downstream_poly_wkb` | bytes | Downstream water surface (WKB) |
| `geometry` | Point | Facility location (WGS84) |
| `closest_river_overlap_fraction` | float | Fraction (0–1) of the closest HydroRIVERS segment's length that falls inside an EU-Hydro `River_Net_p` polygon (± 30 m buffer) |
| `closest_river_is_sentinel_visible` | bool | True if `closest_river_overlap_fraction ≥ 0.30` — the closest river segment is wide enough to be detectable in Sentinel-2 |
| `n_upstream_sentinel_visible` | int | Number of upstream segments that meet the Sentinel-visibility threshold |
| `n_downstream_sentinel_visible` | int | Number of downstream segments that meet the Sentinel-visibility threshold |
| `has_sentinel_visible_river` | bool | **Summary flag** — True if any of the closest, upstream, or downstream segments is Sentinel-visible; use this column to filter facilities to those where Sentinel-2 water-quality retrieval is feasible |
### `river_data_segments.geoparquet` (1.7 MB)
River segments with direction labels (28,434 entries).
| Column | Type | Description |
|--------|------|-------------|
| `HYRIV_ID` | int | HydroRIVERS segment ID |
| `direction` | string | "upstream" or "downstream" |
| `ORD_STRA` | int | Strahler stream order |
| `DIS_AV_CMS` | float | Average discharge (m³/s) |
| `LENGTH_KM` | float | Segment length (km) |
| `geometry` | LineString | River segment geometry |
## Usage
### Load the dataset
```python
import geopandas as gpd
from shapely import wkb
# Load facilities
facilities = gpd.read_parquet("river_data_facilities.geoparquet")
print(f"Loaded {len(facilities):,} facilities")
# Example: Find facilities in Germany
german = facilities[facilities['countryName'] == 'Germany']
print(f"Germany has {len(german):,} facilities near rivers")
```
### Extract river geometries
```python
# Get a specific facility
facility = facilities[facilities['facilityName'].str.contains('PRECHEZA')].iloc[0]
# Parse WKB geometries
upstream_line = wkb.loads(facility['upstream_line_wkb'])
downstream_line = wkb.loads(facility['downstream_line_wkb'])
upstream_poly = wkb.loads(facility['upstream_poly_wkb'])
downstream_poly = wkb.loads(facility['downstream_poly_wkb'])
print(f"Upstream: {facility['n_upstream']} segments")
print(f"Downstream: {facility['n_downstream']} segments")
```
### Visualize a facility
```python
python visualize_single_facility.py "PRECHEZA"
# Opens facility_map.html in browser
```
### Visualize multiple facilities
```python
python visualize_facilities_rivers.py
# Opens facilities_rivers_map.html with 200 sampled facilities
```
## Scripts
### `river_proximity.py`
Main pipeline that:
1. Loads EEA facilities, HydroRIVERS segments, and EU-Hydro polygons
2. Builds river network graph from NEXT_DOWN field
3. For each facility, finds closest river and splits at nearest point
4. Traces upstream (BFS) and downstream (linear) within distance limits
5. Clips water surface polygons to match river geometries
6. Outputs geoparquet files
### `visualize_single_facility.py`
Creates an interactive Folium map for a single facility showing:
- Green: upstream river and water surface
- Red: downstream river and water surface
- Orange marker: facility location
### `visualize_facilities_rivers.py`
Creates an overview map with sampled facilities and their river associations.
## Source Data
| Dataset | Source | Usage |
|---------|--------|-------|
| Industrial Facilities | [EEA E-PRTR](https://www.eea.europa.eu/data-and-maps/data/industrial-reporting-under-the-industrial-6) | Facility locations & emissions |
| River Network | [HydroRIVERS v1.0](https://www.hydrosheds.org/products/hydrorivers) | River segments & flow direction |
| Water Polygons | [EU-Hydro](https://land.copernicus.eu/imagery-in-situ/eu-hydro) | Water surface geometry |
## Parameters
| Parameter | Value | Description |
|-----------|-------|-------------|
| `max_distance_m` | 1,000 | Max distance from facility to river |
| `upstream_distance_km` | 10 | How far to trace upstream |
| `downstream_distance_km` | 10 | How far to trace downstream |
| `polygon_buffer_m` | 600 | Buffer for polygon clipping |
## Statistics
- **Total facilities processed**: 254,027
- **Facilities near rivers**: 160,576 (63%)
- **Unique upstream segments**: 18,498
- **Unique downstream segments**: 9,936
- **Average upstream parts**: 7.1
- **Average downstream parts**: 3.7
### Sentinel visibility (EU-Hydro `River_Net_p` overlap ≥ 30 %)
| Strahler order | Facilities | % Sentinel-visible |
|---|---:|---:|
| 1 | 43,699 | 22.5 % |
| 2 | 28,113 | 20.5 % |
| 3 | 31,616 | 23.9 % |
| 4 | 24,961 | 42.5 % |
| 5 | 15,709 | 67.8 % |
| 6 | 8,128 | 86.5 % |
| 7 | 8,131 | 97.5 % |
| 8 | 219 | 100.0 % |
- **Facilities with `has_sentinel_visible_river = True`**: 59,568 / 160,576 (37.1 %)
- **Facilities where the *closest* reach is visible**: 23,507 / 160,576 (14.6 %)
Lower-order rates (~20–25 %) are driven by upstream/downstream propagation: a headwater facility may drain into a wider river within the 10 km trace window.
### `facility_timeseries.parquet` (210 MB)
Sentinel-2 water-quality time series for **Sentinel-visible** industrial facilities (both upstream and downstream polygons detectable in 10 m imagery). Produced by fetching the Sentinel Hub Statistical API in P10D bins over 2017–2023 and merging three shards. One row per (facility, direction, 10-day bin).
| Column | Type | Description |
|--------|------|-------------|
| `facility_id` | int | Row index in `river_data_facilities.geoparquet` |
| `direction` | string | `"upstream"` or `"downstream"` |
| `polygon_hash` | string | SHA-256[:16] of the raw WKB polygon bytes (dedup key) |
| `date` | datetime | Start of the 10-day bin |
| `ndci_mean` | float | Mean NDCI over water pixels in bin |
| `ndci_stddev` | float | Std dev of NDCI |
| `ndci_n_valid` | int | Number of valid (water-masked) pixels |
| `turb_mean` | float | Mean turbidity proxy over water pixels |
| `turb_stddev` | float | Std dev of turbidity |
| `turb_n_valid` | int | Number of valid pixels (turbidity) |
| `ndwi_mean` | float | Mean NDWI (water index, quality check) |
| `ndwi_n_valid` | int | Number of valid pixels (NDWI) |
**Coverage:** 9.2 M rows · 23,158 unique facility IDs · 20,755 paired (both directions) · 2017-01-01 → 2023-12-16
### `facility_anomalies_per_bin.parquet` (216 MB)
Per-bin anomaly detection output. One row per paired (facility, 10-day bin) where both upstream and downstream data exist. Produced by `scripts/compute_facility_anomalies.py`.
Pipeline steps applied:
1. Inner-join upstream + downstream on (facility_id, date)
2. Pixel-count quality flags
3. Raw downstream-minus-upstream delta
4. **Spatial detrending**: subtract cross-facility median delta per date to remove regional Sentinel-2 artifacts
5. Robust z-score per (facility_id, quarter) using median + MAD × 1.4826
6. Previous-bin z (persistence check)
7. High-confidence anomaly flag (detrended delta > 0, z > 3, prev-z > 1.5)
| Column | Type | Description |
|--------|------|-------------|
| `facility_id` | int | Facility identifier |
| `date` | datetime | 10-day bin start |
| `quarter` | int | Calendar quarter (1–4), used for seasonal baseline |
| `poly_hash_upstream` | string | Upstream polygon hash |
| `poly_hash_downstream` | string | Downstream polygon hash |
| `ndci_mean_upstream` / `_downstream` | float | NDCI means per direction |
| `ndci_n_valid_upstream` / `_downstream` | int | Valid pixel counts |
| `turb_mean_upstream` / `_downstream` | float | Turbidity means |
| `turb_n_valid_upstream` / `_downstream` | int | Valid pixel counts |
| `valid_bin_ndci` / `valid_bin_turb` | bool | Passes pixel-count quality filter |
| `delta_ndci_raw` | float | Raw downstream − upstream NDCI |
| `date_median_ndci` | float | Cross-facility median NDCI delta on this date (removed artifact) |
| `delta_ndci` | float | Spatially detrended NDCI delta |
| `delta_turb_raw` / `delta_turb` | float | Same for turbidity |
| `baseline_med_ndci` / `baseline_mad_ndci` | float | Seasonal baseline median and MAD |
| `z_delta_ndci` / `z_delta_turb` | float | Robust z-scores of detrended deltas |
| `z_delta_ndci_prev` / `z_delta_turb_prev` | float | Previous-bin z (persistence) |
| `low_baseline_data` | bool | True if < 8 bins in the seasonal group |
| `high_confidence_ndci` / `high_confidence_turb` | bool | Anomaly flag per signal |
| `any_anomaly` | bool | Either signal flagged |
| `event_key` | string | Links to event in `facility_anomalies_events.parquet` (null if not in a kept event) |
**Coverage:** 4.26 M rows · 20,755 facilities · 255 unique dates
### `facility_anomalies_events.parquet` (tiny)
Consolidated pollution events — one row per unique (upstream polygon, downstream polygon, time window) after deduplication. Single-bin events and events where the downstream signal is not worse than upstream are excluded.
| Column | Type | Description |
|--------|------|-------------|
| `event_id` | string | Unique event key (e.g. `12345_e3`) |
| `facility_id` | int | Representative facility for this polygon pair |
| `start_date` | datetime | First flagged bin |
| `end_date` | datetime | Last flagged bin |
| `duration_bins` | int | Number of flagged 10-day bins |
| `peak_z_ndci` | float | Maximum z-score (NDCI) across bins in event |
| `peak_z_turb` | float | Maximum z-score (turbidity) across bins in event |
| `mean_z_ndci` / `mean_z_turb` | float | Mean z-scores over event |
| `signal_type` | string | `"ndci"`, `"turb"`, or `"both"` |
| `poly_hash_upstream` / `poly_hash_downstream` | string | Physical polygon pair (dedup key) |
**Coverage:** 42 events · 36 unique polygon pairs · 2017–2023
**Thresholds used:** z > 3.0, prev-bin z > 1.5, ≥ 2 consecutive bins, detrended delta > 0, seasonal MAD baseline requires ≥ 8 bins per quarter.
## License
CC-BY-4.0. See source datasets for their respective licenses.
## Citation
If you use this dataset, please cite the source datasets:
- Lehner, B., Grill G. (2013): Global river hydrography and network routing: baseline data and new approaches to study the world's large river systems. Hydrological Processes, 27(15): 2171–2186.
- European Environment Agency (EEA) Industrial Emissions Database
- Copernicus EU-Hydro River Network Database