% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/spatial.R
\name{grid}
\alias{grid}
\title{Define a uniform grid for a partitioned spatial join}
\usage{
grid(cellsize, origin = c(0, 0))
}
\arguments{
\item{cellsize}{Cell size: a single number for square cells, or
\code{c(cellsize_x, cellsize_y)}.}

\item{origin}{Grid origin \code{c(x0, y0)} (a cell corner). Default \code{c(0, 0)}.}
}
\value{
A \code{vectra_grid} specification to pass as \code{spatial_join(partition =)}.
}
\description{
Describes the regular grid that \code{\link[=spatial_join]{spatial_join()}} uses to partition two
streamed layers for the both-sides-larger-than-RAM case. Cell \verb{(cx, cy)}
covers \verb{[origin_x + cx * cellsize_x, origin_x + (cx + 1) * cellsize_x)} and
likewise in y, so a coordinate maps to the cell \code{floor((coord - origin) / cellsize)}. Pick a \code{cellsize} comparable to the scale of the join (large
enough that most cells hold a workable shard, small enough that one cell's
features fit in memory); for an extended-on-extended join choose it larger
than the left features.
}
\examples{
grid(1000)
grid(c(0.5, 0.25), origin = c(-180, -90))

}
\seealso{
\code{\link[=spatial_join]{spatial_join()}} for the join it partitions.
}
