| Crates.io | readap |
| lib.rs | readap |
| version | 0.2.0 |
| created_at | 2025-06-30 00:53:54.131183+00 |
| updated_at | 2025-07-01 18:22:54.457464+00 |
| description | A parser for the OpenDAP DAP2 protocol |
| homepage | |
| repository | https://github.com/mpiannucci/readap/readap |
| max_upload_size | |
| id | 1731281 |
| size | 199,474 |
Read OpenDAP binary data with pure rust
with cargo add:
cargo add readap
or Cargo.toml:
[dependencies]
readap = "0.1.0"
let attrs = parse_das_attributes(input).unwrap();
This returns a HashMap containing all of the attributes and their children, within another hashmap
let units: String = attrs["time"]["units"].clone().try_into().unwrap();
let dataset = DdsDataset::from_bytes(&input).unwrap();
let dataset = DodsDataset::from_bytes(&input).unwrap();
Then extract the data and coordinates for a given variable
let mwd = if let DataArray::Int32(mwd) = dataset.variable_data("mean_wave_dir").unwrap() {
mwd
} else {
vec![]
};
let coords = dataset.variable_coords("mean_wave_dir").unwrap();
let time_data: Vec<i32> = coords[0].1.try_into().unwrap();
let url = dataset.query("https://example.com/data")
.select_variable("temperature").unwrap()
.dods_url().unwrap();
With coordinate constraints:
let url = dataset.query("https://example.com/data")
.select_variable("temperature").unwrap()
.select_by_coordinate("time", CoordinateConstraint::range(0, 50)).unwrap()
.select_by_coordinate("latitude", CoordinateConstraint::single(0)).unwrap()
.dods_url().unwrap();
For concrete examples, see the parse tests
This library is an OpenDAP binary data and metadata parser. It is not a data downloader. It is a lower level tool to be used in higher level data access applications.
MIT - 2025 Matthew Iannucci