% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sp_from_data_frame.R
\name{sp_from_data_frame}
\alias{sp_from_data_frame}
\title{Function to promote a data frame to a SpatialPointsDataFrame, 
SpatialLinesDataFrame, or SpatialPolygonsDataFrame.}
\usage{
sp_from_data_frame(
  df,
  type = "points",
  latitude = "latitude",
  longitude = "longitude",
  projection = projection_wgs84(),
  keep = FALSE,
  id = NA,
  warn = TRUE
)
}
\arguments{
\item{df}{Data frame to be converted into spatial data frame.}

\item{type}{Type of geometry. Type must be one of \code{"points"}, 
\code{"lines"}, or \code{"polygons"}.}

\item{latitude}{\code{df}'s latitude variable name.}

\item{longitude}{\code{df}'s longitude variable name.}

\item{projection}{\code{df}'s latitude and longitude projection system. 
Default is WGS84.}

\item{keep}{For when type is \code{"points"}, should latitude and longitude
be kept in the SpatialPointsDataFrame's data slot?}

\item{id}{Variable in \code{df} which codes for spatial object's id. This is
used when a data frame contains many separate geometries. \code{id} is not 
used for points because each point is a separate geometry.}

\item{warn}{Should the function raise a warning when observations are 
removed?}
}
\value{
A SpatialPointsDataFrame, SpatialLinesDataFrame, or 
SpatialPolygonsDataFrame.
}
\description{
Function to promote a data frame to a SpatialPointsDataFrame, 
SpatialLinesDataFrame, or SpatialPolygonsDataFrame.
}
\examples{
\dontrun{

# Promote to different geometry types
# Points
sp_points <- sp_from_data_frame(data_drawn, type = "points")

# Lines
sp_lines <- sp_from_data_frame(data_drawn, type = "lines")
# Lines with seperate geometries
sp_lines <- sp_from_data_frame(data_drawn, type = "lines", id = "name")

# Polygons
sp_polygons <- sp_from_data_frame(data_drawn, type = "polygons")
# Polygons with seperate geometries
sp_polygons <- sp_from_data_frame(data_drawn, type = "polygons", id = "name")

}

}
\seealso{
\code{\link{sp_from_wkt}}
}
\author{
Stuart K. Grange
}
