def calculate_default_transform(
        src_crs,
        dst_crs,
        width,
        height,
        left,
        bottom,
        right,
        top,
        resolution=None):
    """Calculate parameters for reproject function.

    Transforms bounds to destination coordinate system, calculates resolution
    if not provided, and returns destination transform and dimensions.
    Intended to be used to calculate parameters for reproject function.

    Destination transform is anchored from the left, top coordinate.

    Destination width and height (and resolution if not provided), are
    calculated using GDAL's method for suggest warp output.

    Parameters
    ----------
    src_crs: dict
        Source coordinate reference system, in rasterio dict format.
        Example: {'init': 'EPSG:4326'}
    dst_crs: dict
        Target coordinate reference system.
    width: int
        Source raster width.
    height: int
        Source raster height.
    left, bottom, right, top: float
        Bounding coordinates in src_crs, from the bounds property of a raster.
    resolution: tuple (x resolution, y resolution) or float, optional
        Target resolution, in units of target coordinate reference system.

    Returns
    -------
    tuple of destination affine transform, width, and height

    Note
    ----
    Should be called within a raster.env.Env() context

    Some behavior of this function is determined by the
    CHECK_WITH_INVERT_PROJ environment variable
        YES: constrain output raster to extents that can be inverted
             avoids visual artifacts and coordinate discontinuties.
        NO:  reproject coordinates beyond valid bound limits
    """
    rasterio.env.setenv()
    dst_affine, dst_width, dst_height = _calculate_default_transform(
        src_crs, dst_crs,
        width, height,
        left, bottom, right, top)

    # If resolution is specified, Keep upper-left anchored
    # adjust the transform resolutions
    # adjust the width/height by the ratio of estimated:specified res (ceil'd)
    if resolution:

        # resolutions argument into tuple
        try:
            res = (float(resolution), float(resolution))
        except TypeError:
            res = (resolution[0], resolution[0]) \
                if len(resolution) == 1 else resolution[0:2]

        # Assume yres is provided as positive,
        # needs to be negative for north-up affine
        xres = res[0]
        yres = -res[1]

        xratio = dst_affine.a / xres
        yratio = dst_affine.e / yres

        dst_affine = Affine(xres, dst_affine.b, dst_affine.c,
                            dst_affine.d, yres, dst_affine.f)

        dst_width = ceil(dst_width * xratio)
        dst_height = ceil(dst_height * yratio)

    return dst_affine, dst_width, dst_height
dataset/ETHPy150Open mapbox/rasterio/rasterio/warp.py/calculate_default_transform/original