vrt.create_warped_vrt()
Create a warped VRT reprojecting a raster onto a fixed target grid.
Usage
vrt.create_warped_vrt(
src_path,
output_vrt,
*,
crs,
resolution,
bounds=None,
resampling=Resampling.average,
snap=True,
dtype=None,
nodata=None
)With snap, the grid origin grows outward to a multiple of resolution, so warps of several sources land on one common grid. Heights are shifted between vertical datums when both CRSs are compound or 3D.
Parameters
src_path: str | Path | UPath-
Source raster; may be a VRT.
output_vrt: str | Path | UPath-
Output VRT, written with an absolute source path so it can live anywhere.
crs: rasterio.crs.CRS or str-
Target CRS.
resolution: float or tuple of float or None-
Target pixel size, or
(x, y)sizes, in units ofcrs.Nonetakes the gridrasterio.warp.calculate_default_transformderives. bounds: rasterio.coords.BoundingBox or tuple of float or None = None-
Target extent as
(left, bottom, right, top), incrs. Defaults to the reprojected extent of the source. resampling: rasterio.enums.Resampling = Resampling.average-
Warp kernel;
averagesuits downsampling to a coarser target. snap: bool = True-
Snap the derived extent onto the target pixel grid. Ignored when
boundsis given. dtype: str or None = None-
Data type of the warped band. Defaults to the source’s; promote to float so an averaging warp yields a mean, not a rounded count.
nodata: float or None = None-
NODATA value of the warped band. Defaults to the source’s. Pass alongside
dtypewhen the promoted type can’t hold the source’s sentinel, e.g. a 0 count becoming NaN.
Raises
ValueError-
If
resolutionis not positive,boundsis given and does not lie on theresolutiongrid, no exact transformation is available (e.g. a datum grid is missing), only one of the source CRS andcrshas a vertical datum, or the nodata (nodata, else the source’s) does not fit in the warped dtype.