% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/featured_space_raster.R
\name{maxent_featured_space_from_rast}
\alias{maxent_featured_space_from_rast}
\title{Create a FeaturedSpace directly from a terra SpatRaster}
\usage{
maxent_featured_space_from_rast(
  rast,
  sample_indices,
  feature_types = c("linear", "quadratic", "product", "threshold", "hinge"),
  n_thresholds = 10L,
  n_hinges = 10L,
  enable_streaming_eval = TRUE
)
}
\arguments{
\item{rast}{A \code{terra::SpatRaster} with one layer per environmental
variable. Layers must be named; names are passed through to
\code{\link{maxent_generate_features}} so generated features carry the
same identifiers as the layer names (e.g. \code{bio1^2}, \code{bio1*bio2}).}

\item{sample_indices}{Integer vector: 0-based indices of occurrence
samples in the concatenated stream of finite background cells. See
\code{\link{maxent_raster_sample_indices}} for a helper that converts
occurrence \code{data.frame}s into these indices.}

\item{feature_types}{Character vector of feature types to generate.
Any subset of \code{c("linear", "quadratic", "product", "threshold",
"hinge")}. Defaults to all types.}

\item{n_thresholds}{Integer; number of threshold knots per variable.}

\item{n_hinges}{Integer; number of hinge knots per variable.}

\item{enable_streaming_eval}{Logical; when \code{TRUE}, enables
streaming-evaluation mode after object construction.}
}
\value{
External pointer to a \code{FeaturedSpace} object.
}
\description{
Streams a \code{terra::SpatRaster} block-by-block into the C++
\code{FeaturedSpace} streaming constructor, filtering NA cells on the fly
and handing the concatenated (\code{num_points} x \code{nlyr(rast)})
matrix to \code{\link{maxent_generate_features}} so feature objects are
built inside C++ without the R caller having to materialise the full
raster stack first.
}
\details{
This is the Phase E.2 entry point described in
\code{docs/ARCHITECTURE_terra_raster.md} (sections 3.1 and 3.2). The
result is bit-for-bit identical to the dense path
(\code{\link{maxent_generate_features}} -> \code{\link{maxent_featured_space}})
when the same data, sample indices, and feature configuration are used.
}
\examples{
\donttest{
stack_path <- system.file("extdata", "stack_1_12_crop.rds",
                         package = "maxentcpp")
r <- terra::unwrap(readRDS(stack_path))
fs <- maxent_featured_space_from_rast(
    r,
    sample_indices = c(0L, 1L, 2L),
    feature_types  = c("linear", "quadratic")
)
}
}
\seealso{
\code{\link{maxent_featured_space}},
  \code{\link{maxent_featured_space_from_callback}},
  \code{\link{maxent_generate_features}}.
}
