def cells_to_h3shape()

in src/h3/api/basic_int/__init__.py [0:0]


def cells_to_h3shape(cells, tight=True):
    """
    Return a H3MultiPoly describing the area covered by a set of H3 cells.

    Parameters
    ----------
    cells : iterable of H3 cells
    tight : bool
        If True, return H3Poly if possible. If False, always return H3MultiPoly

    Returns
    -------
    H3Poly | H3MultiPoly

    Examples
    --------

    >>> cells = ['8428309ffffffff', '842830dffffffff']
    >>> h3.cells_to_h3shape(cells, tight=True)
    <H3Poly: [10]>
    >>> h3.cells_to_h3shape(cells, tight=False)
    <H3MultiPoly: [10]>
    """
    cells = _in_collection(cells)
    mpoly = _cy.cells_to_multi_polygon(cells)

    polys = [H3Poly(*poly) for poly in mpoly]
    out = H3MultiPoly(*polys)

    if tight and len(out) == 1:
        out = out[0]

    return out