rasterio._warp module

Raster and vector warping and reprojection.

class rasterio._warp.WarpedVRTReaderBase

Bases: DatasetReaderBase


The dataset’s coordinate reference system

read(indexes=None, out=None, window=None, masked=False, out_shape=None, resampling=Resampling.nearest, fill_value=None, out_dtype=None, **kwargs)

Read a dataset’s raw pixels as an N-d array

This data is read from the dataset’s band cache, which means that repeated reads of the same windows may avoid I/O.

  • indexes (list of ints or a single int, optional) – If indexes is a list, the result is a 3D array, but is a 2D array if it is a band index number.

  • out (numpy ndarray, optional) –

    As with Numpy ufuncs, this is an optional reference to an output array into which data will be placed. If the height and width of out differ from that of the specified window (see below), the raster image will be decimated or replicated using the specified resampling method (also see below).

    Note: the method’s return value may be a view on this array. In other words, out is likely to be an incomplete representation of the method’s results.

    This parameter cannot be combined with out_shape.

  • out_dtype (str or numpy dtype) – The desired output data type. For example: ‘uint8’ or rasterio.uint16.

  • out_shape (tuple, optional) –

    A tuple describing the shape of a new output array. See out (above) for notes on image decimation and replication.

    Cannot combined with out.

  • window (a pair (tuple) of pairs of ints or Window, optional) – The optional window argument is a 2 item tuple. The first item is a tuple containing the indexes of the rows at which the window starts and stops and the second is a tuple containing the indexes of the columns at which the window starts and stops. For example, ((0, 2), (0, 2)) defines a 2x2 window at the upper left of the raster dataset.

  • masked (bool, optional) – If masked is True the return value will be a masked array. Otherwise (the default) the return value will be a regular array. Masks will be exactly the inverse of the GDAL RFC 15 conforming arrays returned by read_masks().

  • resampling (Resampling) – By default, pixel values are read raw or interpolated using a nearest neighbor algorithm from the band cache. Other resampling algorithms may be specified. Resampled pixels are not cached.

  • fill_value (scalar) – Fill value applied in the boundless=True case only.

  • kwargs (dict) – This is only for backwards compatibility. No keyword arguments are supported other than the ones named above.


  • Numpy ndarray or a view on a Numpy ndarray

  • Note (as with Numpy ufuncs, an object is returned even if you)

  • use the optional out argument and the return value shall be

  • preferentially used by callers.

read_masks(indexes=None, out=None, out_shape=None, window=None, resampling=Resampling.nearest, **kwargs)

Read raster band masks as a multidimensional array

rasterio._warp.recursive_round(val, precision)

Recursively round coordinates.