def to_geotiff(arr, path='<STR_LIT>', proj=None, spec=None, bands=None, **kwargs):
assert has_rasterio, "<STR_LIT>" <EOL>try:<EOL><INDENT>img_md = arr.rda.metadata["<STR_LIT:image>"]<EOL>x_size = img_md["<STR_LIT>"]<EOL>y_size = img_md["<STR_LIT>"]<EOL><DEDENT>except (AttributeError, KeyError):<EOL><INDENT>x_size = kwargs.get("<STR_LIT>", <NUM_LIT>)<EOL>y_size = kwargs.get("<STR_LIT>", <NUM_LIT>)<EOL><DEDENT>try:<EOL><INDENT>tfm = kwargs['<STR_LIT>'] if '<STR_LIT>' in kwargs else arr.affine<EOL><DEDENT>except:<EOL><INDENT>tfm = None<EOL><DEDENT>dtype = arr.dtype.name if arr.dtype.name != '<STR_LIT>' else '<STR_LIT>' <EOL>if spec is not None and spec.lower() == '<STR_LIT>':<EOL><INDENT>if bands is None:<EOL><INDENT>bands = arr._rgb_bands<EOL><DEDENT>if not arr.options.get('<STR_LIT>'):<EOL><INDENT>from gbdxtools.rda.interface import RDA<EOL>rda = RDA()<EOL>dra = rda.HistogramDRA(arr)<EOL>arr = dra.aoi(bbox=arr.bounds)<EOL><DEDENT>arr = arr[bands,...].astype(np.uint8)<EOL>dtype = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>if bands is not None:<EOL><INDENT>arr = arr[bands,...]<EOL><DEDENT><DEDENT>meta = {<EOL>'<STR_LIT:width>': arr.shape[<NUM_LIT:2>],<EOL>'<STR_LIT>': arr.shape[<NUM_LIT:1>],<EOL>'<STR_LIT:count>': arr.shape[<NUM_LIT:0>],<EOL>'<STR_LIT>': dtype,<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': tfm<EOL>}<EOL>if proj is not None:<EOL><INDENT>meta["<STR_LIT>"] = {'<STR_LIT>': proj}<EOL><DEDENT>if "<STR_LIT>" in kwargs and kwargs["<STR_LIT>"]:<EOL><INDENT>meta.update(blockxsize=x_size, blockysize=y_size, tiled="<STR_LIT:yes>")<EOL><DEDENT>with rasterio.open(path, "<STR_LIT:w>", **meta) as dst:<EOL><INDENT>writer = rio_writer(dst)<EOL>result = store(arr, writer, compute=False)<EOL>result.compute(scheduler=threaded_get)<EOL><DEDENT>return path<EOL>
Write out a geotiff file of the image

    Args:
        path (str): path to write the geotiff file to, default is ./output.tif
        proj (str): EPSG string of projection to reproject to
        spec (str): if set to 'rgb', write out color-balanced 8-bit RGB tif
        bands (list): list of bands to export. If spec='rgb' will default to RGB bands

    Returns:
        str: path the geotiff was written to