\Header{surf.ls}{Fits a Trend Surface by Least-squares}
\keyword{spatial}{surf.ls}
\begin{Description}\relax
Fits a trend surface by least-squares.\end{Description}
\begin{Usage}
\begin{verbatim}
surf.ls(np, x, y, z)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{np}] degree of polynomial surface

\item[\code{x}] x coordinates or a data frame with columns \code{x}, \code{y}, \code{z}

\item[\code{y}] y coordinates

\item[\code{z}] z coordinates. Will supersede \code{x\$z}

\end{ldescription}
\end{Arguments}
\begin{Value}
list with components 

\begin{ldescription}
\item[\code{beta}] the coefficients

\item[\code{x}] 
\item[\code{y}] 
\item[\code{z}] and others for internal use only.

\end{ldescription}
\end{Value}
\begin{SeeAlso}\relax
\code{\Link{trmat}}, \code{\Link{surf.gls}}\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
data(topo)
topo.kr <- surf.ls(2, topo)
trsurf <- trmat(topo.kr, 0, 6.5, 0, 6.5, 50)
contour(trsurf)
points(topo)
\end{ExampleCode}
\end{Examples}

