Skip to main content

Crate oxigeo_vrt

Crate oxigeo_vrt 

Source
Expand description

OxiGeo VRT Driver - Pure Rust VRT (Virtual Raster) Support

This crate provides a pure Rust implementation of GDAL’s VRT (Virtual Raster) format, enabling efficient multi-file processing and on-the-fly transformations.

§VRT Format

VRT (Virtual Raster) is an XML-based format that references other raster files without copying data. This enables:

  • Mosaicking: Combine multiple tiles into a single virtual dataset
  • Subsetting: Extract specific bands from multi-band rasters
  • Transformation: Apply on-the-fly scaling, offset, and pixel functions
  • Windowing: Create virtual subsets of large rasters

§Features

  • std (default) - Enable standard library support
  • async - Enable async I/O support

§Examples

§Create a Simple VRT Mosaic

use oxigeo_vrt::VrtBuilder;

let vrt = VrtBuilder::new()
    .add_tile("/data/tile1.tif", 0, 0, 512, 512)?
    .add_tile("/data/tile2.tif", 512, 0, 512, 512)?
    .add_tile("/data/tile3.tif", 0, 512, 512, 512)?
    .add_tile("/data/tile4.tif", 512, 512, 512, 512)?
    .build_file("mosaic.vrt")?;

println!("Created VRT: {}x{}", vrt.raster_x_size, vrt.raster_y_size);

§Read from a VRT

use oxigeo_vrt::VrtReader;

let reader = VrtReader::open("mosaic.vrt")?;
println!("VRT dimensions: {}x{}", reader.width(), reader.height());
println!("Bands: {}", reader.band_count());

// Read a band (lazy evaluation - only reads from source files as needed)
let band_data = reader.read_band(1)?;

§Create a Multi-Band VRT

use oxigeo_vrt::{VrtBuilder, VrtBand, VrtSource, SourceFilename};
use oxigeo_core::types::RasterDataType;

let mut builder = VrtBuilder::with_size(1024, 1024);

// Band 1: Red
let red_source = VrtSource::new(SourceFilename::absolute("/data/red.tif"), 1);
let red_band = VrtBand::simple(1, RasterDataType::UInt8, red_source);
builder = builder.add_band(red_band)?;

// Band 2: Green
let green_source = VrtSource::new(SourceFilename::absolute("/data/green.tif"), 1);
let green_band = VrtBand::simple(2, RasterDataType::UInt8, green_source);
builder = builder.add_band(green_band)?;

// Band 3: Blue
let blue_source = VrtSource::new(SourceFilename::absolute("/data/blue.tif"), 1);
let blue_band = VrtBand::simple(3, RasterDataType::UInt8, blue_source);
builder = builder.add_band(blue_band)?;

let vrt = builder.build_file("rgb.vrt")?;

§Use Mosaic Builder for Grid Layout

use oxigeo_vrt::MosaicBuilder;

let mosaic = MosaicBuilder::new(256, 256)
    .add_tile("/tile_0_0.tif")?
    .next_column()
    .add_tile("/tile_1_0.tif")?
    .next_row()
    .add_tile("/tile_0_1.tif")?
    .next_column()
    .add_tile("/tile_1_1.tif")?
    .with_srs("EPSG:4326")
    .build_file("grid.vrt")?;

§Architecture

The VRT driver is organized into several modules:

  • error - Error types for VRT operations
  • source - Source raster references and windowing
  • band - Virtual band configuration
  • dataset - VRT dataset definition
  • xml - XML parser and writer
  • builder - Fluent builder API
  • reader - Lazy reader with caching
  • mosaic - Mosaicking and compositing logic

Re-exports§

pub use band::ColorEntry;
pub use band::ColorTable;
pub use band::PixelFunction;
pub use band::VrtBand;
pub use builder::MosaicBuilder;
pub use builder::VrtBuilder;
pub use dataset::VrtDataset;
pub use dataset::VrtMetadata;
pub use dataset::VrtSubclass;
pub use error::Result;
pub use error::VrtError;
pub use mosaic::BlendMode;
pub use mosaic::CompositeParams;
pub use mosaic::MosaicCompositor;
pub use mosaic::MosaicPlanner;
pub use reader::VrtReader;
pub use source::PixelRect;
pub use source::SourceFilename;
pub use source::SourceProperties;
pub use source::SourceWindow;
pub use source::VrtSource;
pub use source_dataset::SourceDataset;
pub use srs::resolve_crs;
pub use warp::GenImgProjTransformer;
pub use warp::InitDest;
pub use warp::ReprojectionTransformer;
pub use warp::WarpBandMapping;
pub use warp::WarpKernel;
pub use warp::WarpOptions;
pub use warp::WarpResampleAlg;
pub use xml::VrtXmlParser;
pub use xml::VrtXmlWriter;

Modules§

band
VRT virtual band configuration
builder
VRT builder API for fluent VRT creation
dataset
VRT dataset definition
error
Error types for VRT operations
mosaic
VRT mosaicking logic for combining multiple sources
reader
VRT reader with lazy evaluation
source
VRT source raster references and windowing
source_dataset
Opening and reading the datasets a VRT references.
srs
Resolving the CRS strings a VRT carries into oxigeo_proj::Crs.
warp
Warped VRT support — the <GDALWarpOptions> element of a VRTDataset subClass="VRTWarpedDataset".
xml
VRT XML format parser and writer

Constants§

DRIVER_DESCRIPTION
VRT driver description
DRIVER_NAME
VRT driver name
VERSION
VRT driver version

Functions§

is_vrt
Checks if data looks like a VRT file