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.
- Parameters
- stac_itemslist
This should be a list of dicts, compatible with the stac-pydantic ItemCollection model. The items should have the following proj STAC extension items
proj:epsg
proj:transform
proj:shape
proj:bbox
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 theproj: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 fromproj:bbox
if present. Otherwise,bbox
, reprojected tocrs
.
- data_typestr
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.
- add_prefixbool
Whether to add the GDAL prefix to each href’s source. By default,
/vsicurl
is prepended to http(s) prefixes.
- Returns
- vrtstr
The VRT as a string. This should be a valid XML file. It can also be passed directly to
rasterio.open()
orrioxarray.open_rasterio()
.