% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/duckspatial_df.R
\name{as_duckspatial_df}
\alias{as_duckspatial_df}
\alias{as_duckspatial_df.duckspatial_df}
\alias{as_duckspatial_df.sf}
\alias{as_duckspatial_df.tbl_duckdb_connection}
\alias{as_duckspatial_df.tbl_lazy}
\alias{as_duckspatial_df.character}
\alias{as_duckspatial_df.data.frame}
\title{Convert objects to duckspatial_df}
\usage{
as_duckspatial_df(x, conn = NULL, crs = NULL, geom_col = NULL, ...)

\method{as_duckspatial_df}{duckspatial_df}(x, conn = NULL, crs = NULL, geom_col = NULL, ...)

\method{as_duckspatial_df}{sf}(x, conn = NULL, crs = NULL, geom_col = NULL, ...)

\method{as_duckspatial_df}{tbl_duckdb_connection}(x, conn = NULL, crs = NULL, geom_col = NULL, ...)

\method{as_duckspatial_df}{tbl_lazy}(x, conn = NULL, crs = NULL, geom_col = NULL, ...)

\method{as_duckspatial_df}{character}(x, conn = NULL, crs = NULL, geom_col = NULL, ...)

\method{as_duckspatial_df}{data.frame}(x, conn = NULL, crs = NULL, geom_col = NULL, ...)
}
\arguments{
\item{x}{Object to convert (sf, tbl_lazy, data.frame, or table name)}

\item{conn}{DuckDB connection (required for character table names)}

\item{crs}{CRS object or string. Auto-detected from \code{sf} objects and
persistent DuckDB tables.}

\item{geom_col}{Geometry column name (default: "geom")}

\item{...}{Additional arguments passed to methods:
\describe{
\item{\code{coords}}{Character vector of length 2 for point ingestion}
\item{\code{wkt}}{Character name of WKT column for ingestion}
\item{\code{remove}}{Logical. If TRUE (default), coordinate/WKT columns are removed}
\item{\code{na.fail}}{Logical. If TRUE (default), errors on missing values}
}}
}
\value{
A duckspatial_df object
}
\description{
\code{as_duckspatial_df()} creates a lazy spatial data frame (\code{duckspatial_df}) from
various inputs. When \code{x} is a table name (character) or an existing DuckDB
table (\code{tbl_duckdb_connection}), the function creates a zero-copy representation
of the data directly from the database without loading it into memory. This is
the canonical way to "register" or wrap existing persistent spatial tables.

\strong{CRS Persistence:} \code{duckspatial} reads native DuckDB 1.5.0+ CRS metadata
and, for compatibility with files written by older versions of \code{duckspatial},
CRS metadata stored in column comments. DuckDB files saved in pre-1.5.0
format without \code{duckspatial}-managed comments will not have CRS information
and will default to \code{NA} with a warning.
}
