% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/transform_coordinates.R
\name{transform_coordinates}
\alias{transform_coordinates}
\title{Function to convert coordinates within a data frame.}
\usage{
transform_coordinates(
  df,
  latitude = "latitude",
  longitude = "longitude",
  from,
  to
)
}
\arguments{
\item{df}{Data frame with coordinates to be transformed.}

\item{latitude}{Name of latitude/y variable.}

\item{longitude}{Name of longitude/x variable.}

\item{from}{A proj4 string which represents what coordinate system the
data frame's coordinates are in.}

\item{to}{A proj4 string which represents what coordinate system the 
converted coordinates will be converted to.}
}
\value{
Tibble.
}
\description{
\code{transform_coordinates} converts coordinate pairs from one projection 
system to another. \code{transform_coordinates} is useful when tabular data 
are supplied and the coordinate system is different that what is desired.
}
\details{
\code{transform_coordinates} works by coercing the input data frame to a 
spatial object, applies \code{spTransform} to convert the coordinates, 
converts the spatial object back to a data frame and then returns the data 
frame with the transformed coordinates. The transformed coordinates can be 
optionally renamed and reordered. 

\code{transform_coordinates} requires a CRS projection string for the 
\code{from} and \code{to} arguments. \code{to} by default is set as 
WGS 84/EPSG:4326 (\code{+proj=longlat +datum=WGS84}).
}
\examples{

\dontrun{

# Convert British National Grid/Ordnance Survey National Grid/OSGB36/EPSG:7405
# to latitude and longitude (WGS 84/EPSG:4326)

data_oxford_transform <- transform_coordinates(
  data_oxford, 
  latitude = "latitude", 
  longitude = "longitude", 
  from = projection_bng()
)
  
}

}
\seealso{
\code{\link{sp_transform}}, \code{\link{sp_from_data_frame}}
}
\author{
Stuart K. Grange
}
