def initialize_forecast_exporter_geotiff(
    outpath,
    outfnprefix,
    startdate,
    timestep,
    n_timesteps,
    shape,
    metadata,
    n_ens_members=1,
    incremental=None,
    **kwargs,
):
    """
    Initialize a GeoTIFF forecast exporter.

    The output files are named as '<outfnprefix>_<startdate>_<t>.tif', where
    startdate is in YYmmddHHMM format and t is lead time (minutes). GDAL needs
    to be installed to use this exporter.

    Parameters
    ----------
    outpath: str
        Output path.

    outfnprefix: str
        Prefix for output file names.

    startdate: datetime.datetime
        Start date of the forecast.

    timestep: int
        Time step of the forecast (minutes).

    n_timesteps: int
        Number of time steps in the forecast. This argument is ignored if
        incremental is set to 'timestep'.

    shape: tuple of int
        Two-element tuple defining the shape (height,width) of the forecast
        grids.

    metadata: dict
        Metadata dictionary containing the projection,x1,x2,y1,y2 and unit
        attributes described in the documentation of
        :py:mod:`pysteps.io.importers`.

    n_ens_members: int
        Number of ensemble members in the forecast.

    incremental: {None,'timestep'}, optional
        Allow incremental writing of datasets into the GeoTIFF files. Set to
        'timestep' to enable writing forecasts or forecast ensembles separately
        for each time step. If set to None, incremental writing is disabled and
        the whole forecast is written in a single function call. The 'member'
        option is not currently implemented.

    Returns
    -------
    exporter: dict
        The return value is a dictionary containing an exporter object.
        This can be used with
        :py:func:`pysteps.io.exporters.export_forecast_dataset`
        to write the datasets.

    """

    if len(shape) != 2:
        raise ValueError("shape has %d elements, 2 expected" % len(shape))

    del kwargs  # kwargs not used

    if not GDAL_IMPORTED:
        raise MissingOptionalDependency(
            "gdal package is required for GeoTIFF " "exporters but it is not installed"
        )

    if incremental == "member":
        raise ValueError(
            "incremental writing of GeoTIFF files with"
            + " the 'member' option is not supported"
        )

    exporter = dict(
        method="geotiff",
        outfnprefix=outfnprefix,
        startdate=startdate,
        timestep=timestep,
        num_timesteps=n_timesteps,
        shape=shape,
        metadata=metadata,
        num_ens_members=n_ens_members,
        incremental=incremental,
        dst=[],
    )
    driver = gdal.GetDriverByName("GTiff")
    exporter["driver"] = driver

    if incremental != "timestep":
        for i in range(n_timesteps):
            outfn = _get_geotiff_filename(
                outfnprefix, startdate, n_timesteps, timestep, i
            )
            outfn = os.path.join(outpath, outfn)
            dst = _create_geotiff_file(outfn, driver, shape, metadata, n_ens_members)
            exporter["dst"].append(dst)
    else:
        exporter["num_files_written"] = 0

    return exporter
Initialize a GeoTIFF forecast exporter.

The output files are named as '<outfnprefix>_<startdate>_<t>.tif', where
startdate is in YYmmddHHMM format and t is lead time (minutes). GDAL needs
to be installed to use this exporter.

Parameters
----------
outpath: str
Output path.

outfnprefix: str
Prefix for output file names.

startdate: datetime.datetime
Start date of the forecast.

timestep: int
Time step of the forecast (minutes).

n_timesteps: int
Number of time steps in the forecast. This argument is ignored if
incremental is set to 'timestep'.

shape: tuple of int
Two-element tuple defining the shape (height,width) of the forecast
grids.

metadata: dict
Metadata dictionary containing the projection,x1,x2,y1,y2 and unit
attributes described in the documentation of
:py:mod:`pysteps.io.importers`.

n_ens_members: int
Number of ensemble members in the forecast.

incremental: {None,'timestep'}, optional
Allow incremental writing of datasets into the GeoTIFF files. Set to
'timestep' to enable writing forecasts or forecast ensembles separately
for each time step. If set to None, incremental writing is disabled and
the whole forecast is written in a single function call. The 'member'
option is not currently implemented.

Returns
-------
exporter: dict
The return value is a dictionary containing an exporter object.
This can be used with
:py:func:`pysteps.io.exporters.export_forecast_dataset`
to write the datasets.
pysteps/io/exporters.py