Skip to content

CLI_nc2rline

Carles Tena edited this page Oct 6, 2026 · 1 revision

️ nc2rline

The nc2rline command converts a NetCDF file into RLINE line-source CSVs using a roads geometry (GeoJSON/Shapefile). It can generate one CSV per pollutant (using a filename placeholder) and optionally export a companion geometry CSV in an RLINE-friendly layout.

Table of Contents


Usage

nes nc2rline \
  -i INPUT.nc \
  -o OUTPUT.csv \
  -g ROADS.{geojson|shp} \
  [--crs EPSG:4326] \
  [--output_geometry_file GEOM.csv] \
  [--index_column ROAD_ID] \
  [--weight_column WEIGHT] \
  [--weight_file WEIGHTS.csv] \
  [-l VAR1 VAR2 ...]

Use -h or --help to view the full list of available options:

nes nc2rline --help

Arguments

Argument Description
-i, --input_file (required) Path to the input NetCDF file to transform to RLINE format.
-o, --output_file (required) Output CSV path for RLINE emissions.
Filename behavior: if it contains the placeholder <pollutant>, it will be replaced by each variable name to produce one CSV per pollutant. Otherwise, the variable name will be appended before the .csv extension in a single filename template.
-g, --geometry (required) Roads geometry file (GeoJSON or Shapefile) providing line features.
--crs CRS to use for reprojection (e.g., EPSG:4326 or a PROJ string). If omitted, the CRS from the geometry file is used.
--output_geometry_file Optional path to write an RLINE-compatible geometry CSV alongside emissions.
--index_column Column name in the geometry to use as a unique line index (e.g., road_id).
--weight_column Column name in the geometry to use as weight (e.g., traffic-based weight).
--weight_file Path to an auxiliary weights CSV. If the file exists, it is read and used; if it does not exist, it will be written for future runs (cache/reuse).
-l, --var_list Space-separated list of NetCDF variables (pollutants) to include. If omitted, all variables are processed.

Notes

  • Per-pollutant outputs: Use <pollutant> in --output_file to force one file per variable. Without it, the tool appends the variable name before .csv.

    • Example: --output_file rline_<pollutant>.csv → rline_NO2.csv, rline_PM10.csv, …
    • Example: --output_file rline.csv → rline_NO2.csv, rline_PM10.csv, … (name appended before extension)
  • CRS handling: If --crs is set, the roads geometry is reprojected to that CRS; otherwise, the geometry file’s native CRS is used.

  • Weights: You can provide weights directly via a geometry column (--weight_column) and/or via a reusable cache (--weight_file).

  • Indexing: --index_column lets you control the stable line identifier written into the RLINE outputs.

Examples

1) Minimal conversion for all pollutants

nes nc2rline \
  -i emissions_202401.nc \
  -o "rline_<pollutant>.csv" \
  -g roads.geojson

Creates one CSV per pollutant using the placeholder.

2) Specific pollutants + explicit CRS

nes nc2rline \
  -i emissions_202401.nc \
  -o "outputs/rline_<pollutant>.csv" \
  -g roads.shp \
  --crs EPSG:4326 \
  -l NO2 PM10

3) Using road index, weights, and caching a weights file

nes nc2rline \
  -i emissions_202401.nc \
  -o "rline_<pollutant>.csv" \
  -g roads.geojson \
  --index_column road_id \
  --weight_column weight \
  --weight_file roads_weights.csv

4) Also write an RLINE-compatible geometry CSV

nes nc2rline \
  -i emissions_202401.nc \
  -o "rline_<pollutant>.csv" \
  -g roads.geojson \
  --output_geometry_file rline_geometry.csv

Clone this wiki locally