## vrt.warp()


Warp a raster or VRT onto another grid.


Usage

``` python
vrt.warp(
    source,
    *,
    crs=None,
    src_crs=None,
    resolution=None,
    bounds=None,
    like=None,
    resampling=Resampling.average,
    snap=True,
    dtype=None,
    nodata=None,
    tolerance="auto",
    allow_ballpark=False
)
```


The pixel type is not promoted: an averaging warp of a `uint16` band stays `uint16` and rounds the mean (1.5 becomes 2). Pass `dtype="float32"` to keep the fraction.


## Parameters


`source: str | Path | UPath | VRT`  
Raster to warp; a [VRT](vrt.VRT.md#freezebase.vrt.VRT) is embedded in the warp.

`crs: CRS | str | None = None`  
Target CRS; required unless `like` is given.

`src_crs: CRS | str | None = None`  
Overrides the source's CRS, e.g. to add the vertical datum its header lacks.

`resolution: float | tuple[float, float] | None = None`  
Target pixel size, or `(x, y)` sizes, in units of `crs`. `None` takes the grid `rasterio.warp.calculate_default_transform` derives.

`bounds: BoundingBox | tuple[float, float, float, float] | None = None`  
Target extent as `(left, bottom, right, top)` in `crs`, a whole number of pixels. Defaults to the reprojected extent of the source. Needs `resolution`.

`like: str | Path | UPath | VRT | None = None`  
Raster whose CRS, transform and size are copied exactly.

`resampling: Resampling = Resampling.average`  
Warp kernel; `average` suits downsampling to a coarser target.

`snap: bool = ``True`  
Grow the derived extent outward onto the `resolution` grid, so warps of several sources share one grid. Applies only with `resolution` and without `bounds`.

`dtype: str | None = None`  
Data type of the warped bands. Defaults to the source's.

`nodata: float | None = None`  
NODATA value of the warped bands. Defaults to the source's, which must then fit in `dtype`. Pass it with `dtype` when the source's sentinel should not stay a valid-looking value, e.g. `nan`.

`tolerance: float | {``"auto"}`` = ``"auto"`  
Error allowed when approximating the transformation, in source pixels; `0` is exact. `"auto"` is 0.125, or 0 when heights are shifted.

`allow_ballpark: bool = ``False`  
Let PROJ fall back to a ballpark transformation, ignoring datum differences, when it lacks a grid or a datum link.


## Returns


`VRT`  
A warped VRT; nothing is written. Heights are shifted between vertical datums, and converted between vertical units, when the source CRS and `crs` differ and both are compound or 3D; the source must then have one band and no scale or offset.


## Raises


`ValueError`  
If neither `crs` nor `like` is given, `like` comes with `crs`, `resolution` or `bounds`, `bounds` comes without `resolution`, `resolution` is not positive, `bounds` does not lie on the `resolution` grid, `tolerance` is negative or NaN, the source has no CRS and no `src_crs` is given, only one of the source CRS and the target CRS has a vertical datum, heights would be shifted in a source of more than one band or with a scale or offset, no exact transformation is available and `allow_ballpark` is false, the source has a colour table, or the nodata (the given one, else the source's) does not fit in the warped dtype.

`RuntimeError`  
If GDAL's serialized transformer cannot be made exact or ballpark-free.
