Re: Problem with passing CRS to warpedVRT

Sean Gillies


If I read your code correctly, you are misusing the WarpedVRT constructor. You are passing a dict as the second positional argument to WarpedVRT(). This ends up being bound to the name src_crs in and then can't be understood by PROJ as a CRS. That is invalid usage. Instead, try

with WarpedVRT(mr, **output_params) as vrt:

This unpacks the dict into the separate keyword arguments that the constructor expects.

On Sun, Jan 2, 2022 at 2:25 PM <stefan.jozefowicz@...> wrote:
I am getting the folllowing error when I am trying pass a crs object to WarpedVRT

rasterio.errors.CRSError: The PROJ4 dict could not be understood. OGR Error code 5
my code:

import rasterio
from rasterio.enums import Resampling
from rasterio.vrt import WarpedVRT
from rasterio import shutil as rio_shutil
from import CRS

def match_raster(master_raster, matched_raster, output_matched_raster, resampling_method=Resampling.bilinear):

# get info of master raster
with as src:
# bounds = src.bounds
crs =
shape = src.shape
transform = src.transform
# resample (and reproject)

output_params = {
'resampling': Resampling.cubic,
'crs': crs,
'transform': transform,
'height': shape[0],
'width': shape[1],

# write to file
with as mr:
with WarpedVRT(mr,output_params) as vrt:
data =
My setup - Ubuntu 20, rasterio 1.2.10, GDAL 3.3.2. Any help will be greatly appreciated

Sean Gillies

Join to automatically receive all group messages.