API Reference

stac_vrt.build_vrt(stac_items, *, crs: Optional[rasterio.crs.CRS] = None, res_x: Optional[float] = None, res_y: Optional[float] = None, shapes: Optional[List[Tuple[int, int]]] = None, bboxes: Optional[List[rasterio.coords.BoundingBox]] = None, data_type=None, block_width=None, block_height=None, add_prefix=True)

Build a GDAL VRT from STAC Metadata.

This can be used to quickly build a mosaic of COGs without needed to open each source file to query its metadata.


This should be a list of dicts, compatible with the stac-pydantic ItemCollection model. The items should have the following proj STAC extension items

  1. proj:epsg

  2. proj:transform

  3. proj:shape

  4. proj:bbox

  5. eo:bands

If proj:epsg is present, all items must have the same epsg.

crsrasterio.crs.CRS, optional

The CRS for the output VRT. Taken from the first STAC item’s proj:epsg if not provided. This is used for the generated VRT’s SRS field, after being converted to GDAL’s WKT format.

res_x, res_y: float, optional

The resolution in the x and y directions. If not specified, this will be taken from the first STAC item’s proj:transform field.

shapeslist of tuples, optional

The shape of each STAC item’s asset, as (height, width). If not provided then this is taken from proj:shape.

bboxeslist of tuples, optional

The bounding box of each STAC item in its projected space. Note this is not the same as the STAC item’s bbox field. Rather, it is the proj:bbox field.

If provided, this should be a list of rasterio.coords.BoundingBox namedtuples the same length as stac_items. If not provided this will be taken from

  1. proj:bbox if present. Otherwise,

  2. bbox, reprojected to crs.


The GDAL raster band data type of the data. https://gdal.org/user/raster_data_model.html#raster-band

block_width, block_heightint

The internal tiling of each COG.


Whether to add the GDAL prefix to each href’s source. By default, /vsicurl is prepended to http(s) prefixes.


The VRT as a string. This should be a valid XML file. It can also be passed directly to rasterio.open() or rioxarray.open_rasterio().