Skip to main content

xvrt

Write GDAL multidimensional VRT from xarray Datasets and STAC catalogues. Pure Python: no GDAL needed to write.

Documentation: https://hypertidy.github.io/xvrt/

A multidimensional VRT is a small XML file that describes a collection of files as one n-dimensional dataset: which file supplies which slab of which array, plus dimensions, coordinates, CRS, units and packing. It holds no data. Any reader of GDAL's multidimensional API opens the whole collection as a single cube and reads only the files a request touches.

Install

pip install xvrt
pip install "xvrt[stac]"   # adds pyarrow and pyproj for from_stac()

Reading the result needs GDAL 3.x with multidimensional support (for example GDAL's Python bindings from conda-forge).

From xarray

Open files the way you normally would, then describe the result:

import glob
import xarray as xr
from xvrt import write_mdim_vrt

paths = sorted(glob.glob("oisst-avhrr-v02r01.*.nc"))   # one day per file
ds = xr.open_mfdataset(paths, combine="nested", concat_dim="time")

write_mdim_vrt(ds, paths, "oisst.vrt", composition="concat", concat_dim="time")

The same works over HTTP. Ten monthly files of one variable from a THREDDS server (URLs become /vsicurl/ sources):

PREFIX = "https://thredds.nci.org.au/thredds/fileServer/gb6/BRAN/BRAN2020/daily"
months = [f"2010_{m:02d}" for m in range(1, 11)]
paths = [f"{PREFIX}/ocean_temp_{ym}.nc" for ym in months]

ds = xr.open_mfdataset(paths, engine="h5netcdf")
write_mdim_vrt(ds[["temp"]], paths, "bran.vrt",
               composition="concat", concat_dim="Time")

From a STAC catalogue

from_stac() builds the VRT from catalogue fields alone (grid, CRS, item datetimes, per-asset band storage) without opening a file:

from xvrt import from_stac

from_stac("https://data.source.coop/ausantarctic/ghrsst-mur-v2/ghrsst-mur-v2.parquet",
          "mur.vrt", block_size=[1, 512, 512])

For the GHRSST MUR collection that is five arrays over 8913 days in a few seconds.

What it handles

  • Compositions: concat (files already have the dimension) and stack (one file per position of a new dimension), with explicit positions and gaps.
  • Packed data: storage dtype, scale, offset and nodata are recovered from xarray's .encoding, so GDAL decodes the stored bytes exactly as xarray did.
  • Time: decoded times are re-encoded with their original CF units and calendar.
  • Multiple variables: in the same files, or one source list per variable.
  • Raster sources: GeoTIFF/COG bands via <SourceBand> and <SourceTranspose>.
  • Lazy reads: every source states its extent (<SourceSlab>), so a read opens only the files it needs.
  • CRS: <SRS> with the data-axis-to-SRS-axis mapping computed from the WKT axis order.

Reading the result

gdal mdim info oisst.vrt
from osgeo import gdal
ds = gdal.OpenEx("oisst.vrt", gdal.OF_MULTIDIM_RASTER)
sst = ds.GetRootGroup().OpenMDArray("sst").GetUnscaled()

or with an xarray backend for GDAL, such as gdalxarray: xr.open_dataset("oisst.vrt", engine="gdalxarray").

Development

pip install -e ".[test]"
pytest tests/

tests/test_gdal_roundtrip.py reads every written VRT back through GDAL and validates it against GDAL's schema (schema/gdalvrt.xsd); it is skipped when osgeo.gdal is not importable. With conda-forge:

micromamba create -n xvrt -c conda-forge python gdal libgdal-netcdf xarray netcdf4 h5netcdf dask lxml pyarrow pyproj pytest

The design notes are in mdim-vrt-writer-plan.md; the documentation site source is in docs/.

License

MIT

Metadata

Release files for xvrt 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xvrt 0.1.0
File Size Uploaded Provenance Actions
xvrt-0.1.0.tar.gz 45.7 kB With provenance Details for xvrt-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xvrt 0.1.0
File Interpreter ABI Platform Actions
xvrt-0.1.0-py3-none-any.whl Python 3 none any Details for xvrt-0.1.0-py3-none-any.whl

Total release size: 77.8 kB

Release files / xvrt-0.1.0.tar.gz

Download URL xvrt-0.1.0.tar.gz
Size 45.7 kB
Tags Source
SHA-256 checksum
How to use checksums
dbfad4e7d84a5d378fa881b49cb07581e78bc98585fb701844c51d57a7b2652d
BLAKE2b-256 checksum
How to use checksums
218469bb69ce2b915e096eeec97c2173b1516cae0f501b5409d57ae3b002ac40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / xvrt-0.1.0-py3-none-any.whl

Download URL xvrt-0.1.0-py3-none-any.whl
Size 32.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
276a2068451bbe3bd453ab7807546a0cd55efacf608aeef7fcd000458a110e6b
BLAKE2b-256 checksum
How to use checksums
77ee138d3a9936f70d0c6ebe851000745f6a512cd29204039ff46dde5e307d6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for xvrt 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for xvrt-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page