docs: def calc_transform(src, dst_crs=None, resolution=None, dimensions=None,
                     src_bounds=None, dst_bounds=None, target_aligned_pixels=False):
      """Output dimensions and transform for a reprojection.
  
      Parameters
      ------------
      src: rasterio.io.DatasetReader
          Data source.
      dst_crs: rasterio.crs.CRS, optional
          Target coordinate reference system.
      resolution: tuple (x resolution, y resolution) or float, optional
          Target resolution, in units of target coordinate reference
          system.
      dimensions: tuple (width, height), optional
          Output file size in pixels and lines.
      src_bounds: tuple (xmin, ymin, xmax, ymax), optional
          Georeferenced extent of output file from source bounds
          (in source georeferenced units).
      dst_bounds: tuple (xmin, ymin, xmax, ymax), optional
          Georeferenced extent of output file from destination bounds
          (in destination georeferenced units).
      target_aligned_pixels: bool, optional
          Align the output bounds based on the resolution.
          Default is `False`.
  
      Returns
      -------
      dst_crs: rasterio.crs.CRS
          Output crs
      transform: Affine
          Output affine transformation matrix
      width, height: int
          Output dimensions
      """
      if resolution is not None:
          if isinstance(resolution, (float, int)):
              resolution = (float(resolution), float(resolution))
  
      if target_aligned_pixels:
          if not resolution:
              raise ValueError('target_aligned_pixels cannot be used without resolution')
          if src_bounds or dst_bounds:
              raise ValueError('target_aligned_pixels cannot be used with src_bounds or dst_bounds')
  
      elif dimensions:
          invalid_combos = (dst_bounds, resolution)
          if any(p for p in invalid_combos if p is not None):
              raise ValueError('dimensions cannot be used with dst_bounds or resolution')
  
      if src_bounds and dst_bounds:
          raise ValueError('src_bounds and dst_bounds may not be specified simultaneously')
  
      if dst_crs is not None:
  
          if dimensions:
              # Calculate resolution appropriate for dimensions
              # in target.
              dst_width, dst_height = dimensions
              bounds = src_bounds or src.bounds
              xmin, ymin, xmax, ymax = transform_bounds(
                  src.crs, dst_crs, *bounds)
              dst_transform = Affine(
                  (xmax - xmin) / float(dst_width),
                  0, xmin, 0,
                  (ymin - ymax) / float(dst_height),
                  ymax
              )
  
          elif src_bounds or dst_bounds:
              if not resolution:
                  raise ValueError('resolution is required when using src_bounds or dst_bounds')
  
              if src_bounds:
                  xmin, ymin, xmax, ymax = transform_bounds(
                      src.crs, dst_crs, *src_bounds)
              else:
                  xmin, ymin, xmax, ymax = dst_bounds
  
              dst_transform = Affine(resolution[0], 0, xmin, 0, -resolution[1], ymax)
              dst_width = max(int(ceil((xmax - xmin) / resolution[0])), 1)
              dst_height = max(int(ceil((ymax - ymin) / resolution[1])), 1)
  
          else:
              if src.transform.is_identity and src.gcps:
                  src_crs = src.gcps[1]
                  kwargs = {'gcps': src.gcps[0]}
              else:
                  src_crs = src.crs
                  kwargs = src.bounds._asdict()
              dst_transform, dst_width, dst_height = calcdt(
                  src_crs, dst_crs, src.width, src.height,
                  resolution=resolution, **kwargs)
  
      elif dimensions:
          # Same projection, different dimensions, calculate resolution.
          dst_crs = src.crs
          dst_width, dst_height = dimensions
          l, b, r, t = src_bounds or src.bounds
          dst_transform = Affine(
              (r - l) / float(dst_width),
              0, l, 0,
              (b - t) / float(dst_height),
              t
          )
  
      elif src_bounds or dst_bounds:
          # Same projection, different dimensions and possibly
          # different resolution.
          if not resolution:
              resolution = (src.transform.a, -src.transform.e)
  
          dst_crs = src.crs
          xmin, ymin, xmax, ymax = (src_bounds or dst_bounds)
          dst_transform = Affine(resolution[0], 0, xmin, 0, -resolution[1], ymax)
          dst_width = max(int(ceil((xmax - xmin) / resolution[0])), 1)
          dst_height = max(int(ceil((ymax - ymin) / resolution[1])), 1)
  
      elif resolution:
          # Same projection, different resolution.
          dst_crs = src.crs
          l, b, r, t = src.bounds
          dst_transform = Affine(resolution[0], 0, l, 0, -resolution[1], t)
          dst_width = max(int(ceil((r - l) / resolution[0])), 1)
          dst_height = max(int(ceil((t - b) / resolution[1])), 1)
  
      else:
          dst_crs = src.crs
          dst_transform = src.transform
          dst_width = src.width
          dst_height = src.height
  
      if target_aligned_pixels:
          dst_transform, dst_width, dst_height = aligned_target(
              dst_transform, dst_width, dst_height, resolution)
  
      return dst_crs, dst_transform, dst_width, dst_height