labeledarray
LabeledArray provides labeled n-dimensional arrays and helpers aimed at geospatial and scientific workflows built on ndarray.
Quick publish notes:
- Ensure Cargo.toml has valid metadata (description, authors, readme, license-file).
- Add a LICENSE file matching the license field.
- Run cargo package to verify the package contents before publishing: cargo package --allow-dirty
See the crate documentation at https://docs.rs/labeledarray (after first publish).
This library provides a structure for connecting human-readable dimension names (like "band", "time", "y", "x") to the underlying numerical data store powered by ndarray.
Features
- Labeled Dimensions: Associate human-readable names with array dimensions
- Coordinate Labels: Attach coordinate labels to dimensions for easy data selection
- Type-Safe: Leverages Rust's type system for safe array operations
- Performance: Built on top of ndarray with optional parallel processing support via rayon
Installation
Add this to your Cargo.toml:
[]
= "0.1"
Quick Start
use ArrayD;
use LabeledArray;
use HashMap;
// Create a simple 2D labeled array
let data = from_shape_vec.unwrap;
let dims = vec!;
let array = new;
println!;
println!;
Geospatial Example
use ArrayD;
use LabeledArray;
use HashMap;
// Create a 4D geospatial array: time × band × y × x
let data = from_shape_vec.unwrap;
let dims = vec!;
let mut coords = new;
coords.insert;
coords.insert;
let array = with_coords;
// Query dimension indices
if let Some = array.dim_index
// Select by coordinate label
if let Some = array.select_by_label
API Overview
Creating Arrays
LabeledArray::new(data, dims)- Create array with dimension namesLabeledArray::with_coords(data, dims, coords)- Create array with dimension names and coordinates
Querying Array Information
dims()- Get dimension namesshape()- Get array shapendim()- Get number of dimensionsdata()- Get reference to underlying ndarrayinfo()- Get formatted string with array information
Working with Coordinates
coords(dim)- Get coordinates for a dimensionall_coords()- Get all coordinatesset_coords(dim, coords)- Set coordinates for a dimensiondim_index(dim)- Get the index of a dimension by nameselect_by_label(dim, label)- Find the index of a coordinate label
Examples
Run the included example:
Future Development
This library is designed to be extended with additional geospatial functionality:
- Integration with geo-types for spatial operations
- STAC (SpatioTemporal Asset Catalog) support
- GDAL bindings for reading/writing geospatial formats
- Advanced indexing and selection operations
- Lazy evaluation and chunked processing
License
[Add your license here]
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.