% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hex_compact.R
\name{hex_compact}
\alias{hex_compact}
\title{Compact Hex Cells}
\usage{
hex_compact(cell_ids, grid)
}
\arguments{
\item{cell_ids}{Cell IDs to compact. For H3 grids, a character vector.
For ISEA grids, a character vector of hierarchical index strings.}

\item{grid}{A HexGridInfo object specifying the grid.}
}
\value{
A character vector of compacted cell IDs. Cells that could be
merged into parents appear as parent IDs at coarser resolution.
}
\description{
Merges child cells into their parent when all children are present.
This is a lossless compression — no spatial information is lost.
The compact representation uses fewer cells to cover the same area.
}
\details{
\strong{H3 backend:} Uses the vendored H3 \code{compactCells} function.

\strong{ISEA backend (aperture 7, Z7 index):} Groups cells by parent index
(dropping the last digit). If all 7 children are present, replaces them
with the parent. Iterates until no further compaction is possible.
}
\examples{
\donttest{
# H3 compaction
g <- hex_grid(resolution = 3, type = "h3")
parent <- "832830fffffffff"
children <- get_children(parent, g)[[1]]
compact <- hex_compact(children, g)
compact  # Should return the parent
}
}
\seealso{
\code{\link[=hex_uncompact]{hex_uncompact()}} for the inverse operation,
\code{\link[=get_parent]{get_parent()}}, \code{\link[=get_children]{get_children()}} for hierarchical operations
}
