nc2parquet
High-performance NetCDF to Parquet converter with advanced filtering, cloud storage, and post-processing.
Features
- Multi-variable extraction — extract one or many variables per pass into a single Parquet file
- Batch processing — convert entire directory trees with a single glob pattern
- Four filter types — range, list, 2D spatial point, and 3D spatiotemporal point with intersection logic
- Post-processing pipeline — rename columns, convert units, apply mathematical formulas, and parse datetime values
- Amazon S3 support — read from and write to S3 buckets with standard AWS credential chains
- Parquet output control — choose compression codec, compression level, row group size, and column statistics
- Multi-source configuration — compose settings from CLI flags, environment variables, and JSON/YAML config files
Installation
Build from Source
# Binary is at target/release/nc2parquet
The
netcdfcrate is compiled withfeatures = ["static"], so HDF5/NetCDF system headers are only required at build time. The resulting binary is self-contained.
Library Dependency
[]
= "0.1"
Quick Start
Basic CLI Conversion
# Convert a single variable to Parquet
# Extract multiple variables into one file
# Batch convert all .nc files under a directory
CLI with Filters and Post-Processing
# Range + list filters, then rename and convert units
Inspect a NetCDF File
# Human-readable file summary
# JSON output for scripting
# Variable-specific detail
Library Usage
use JobConfig;
use process_netcdf_job_async;
async
CLI Reference
| Subcommand | Description |
|---|---|
convert |
Convert a NetCDF file (or glob of files) to Parquet |
validate |
Validate a configuration file without processing any data |
info |
Inspect NetCDF file structure, dimensions, variables, and metadata |
template |
Generate a configuration file template (basic, s3, multi-filter, weather, ocean) |
completions |
Emit shell completion scripts (bash, zsh, fish, PowerShell) |
Global flags available on every subcommand:
| Flag | Env variable | Description |
|---|---|---|
-v / --verbose |
Enable debug logging | |
-q / --quiet |
Suppress all output except errors | |
--output-format |
Structured output format: human, json, yaml, csv |
|
-c / --config <FILE> |
NC2PARQUET_CONFIG |
Load a JSON or YAML configuration file |
Key convert flags:
| Flag | Env variable | Description |
|---|---|---|
-n / --variable <NAME> |
NC2PARQUET_VARIABLE |
Single variable name to extract |
-N / --variables <A,B,...> |
Comma-separated list of variables (multi-column output) | |
--glob <PATTERN> |
Glob pattern for batch processing | |
--range <DIM:MIN:MAX> |
NC2PARQUET_RANGE_FILTERS |
Range filter (repeatable) |
--list <DIM:V1,V2,...> |
NC2PARQUET_LIST_FILTERS |
List filter (repeatable) |
--point2d <DIMS:LAT,LON:TOL> |
NC2PARQUET_POINT2D_FILTERS |
2D spatial point filter (repeatable) |
--point3d <DIMS:T,LAT,LON:TOL> |
NC2PARQUET_POINT3D_FILTERS |
3D spatiotemporal point filter (repeatable) |
--compression <CODEC> |
snappy (default), zstd, gzip, lz4, uncompressed |
|
--compression-level <N> |
Zstd: 1–22; Gzip: 0–9 | |
--row-group-size <ROWS> |
Maximum rows per Parquet row group | |
--no-statistics |
Disable column statistics (min, max, null count) | |
--rename <OLD:NEW> |
Rename output column (repeatable) | |
--unit-convert <COL:FROM:TO> |
Unit conversion (repeatable) | |
--kelvin-to-celsius <COL> |
Shortcut: convert column from Kelvin to Celsius | |
--formula <TARGET:EXPR:SOURCES> |
Apply formula to create a new column (repeatable) | |
--dry-run |
NC2PARQUET_DRY_RUN |
Validate and plan without writing output |
--force |
NC2PARQUET_FORCE |
Overwrite existing output files |
Configuration
Settings are resolved in the following priority order (highest wins):
- CLI arguments
- Environment variables (
NC2PARQUET_*) - Configuration file (
-c / --config)
Both JSON and YAML formats are supported. Generate a starter template with:
See examples/configs/ for complete annotated examples covering
single-file, multi-filter, and S3 scenarios.
Filter Types
All specified filters are intersected — a data point must satisfy every filter to be included.
| Filter | CLI flag | Selects | Format |
|---|---|---|---|
range |
--range |
Dimension values within [min, max] |
DIM:MIN:MAX |
list |
--list |
Specific discrete dimension values | DIM:V1,V2,... |
2d_point |
--point2d |
Grid cells within tolerance of (lat, lon) points |
LAT_DIM,LON_DIM:LAT,LON:TOL |
3d_point |
--point3d |
Time steps + spatial cells within tolerance |
T_DIM,LAT_DIM,LON_DIM:T,LAT,LON:TOL |
See examples/configs/ for JSON/YAML filter configuration examples.
Post-Processing
Processors run sequentially after extraction. Results from earlier steps are available to later steps.
| Processor | CLI flag | Description |
|---|---|---|
| Rename columns | --rename |
Rename one or more output DataFrame columns |
| Unit conversion | --unit-convert |
Convert a column between physical units |
| Kelvin to Celsius | --kelvin-to-celsius |
Shortcut for the common temperature conversion |
| Apply formula | --formula |
Create a new column using a mathematical expression |
| DateTime convert | config only | Convert a numeric time offset to a datetime column |
See examples/postprocessing/ for complete pipeline examples.
Storage
Both local paths and S3 URIs are accepted anywhere a file path is expected:
# Local to local
# S3 to S3
# Mixed
AWS credentials are resolved automatically via the standard AWS credential chain
(environment variables, ~/.aws/credentials, IAM instance roles, etc.).
Contributing
See CONTRIBUTING.md for development setup, branch conventions, and the pull request process.
Changelog
See CHANGELOG.md for release history and upgrade notes.