View source: R/transform_coordinates.R
transform_coordinates | R Documentation |
transform_coordinates
converts coordinate pairs from one projection
system to another. transform_coordinates
is useful when tabular data
are supplied and the coordinate system is different that what is desired.
transform_coordinates(
df,
latitude = "latitude",
longitude = "longitude",
from,
to
)
df |
Data frame with coordinates to be transformed. |
latitude |
Name of latitude/y variable. |
longitude |
Name of longitude/x variable. |
from |
A proj4 string which represents what coordinate system the data frame's coordinates are in. |
to |
A proj4 string which represents what coordinate system the converted coordinates will be converted to. |
transform_coordinates
works by coercing the input data frame to a
spatial object, applies 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.
transform_coordinates
requires a CRS projection string for the
from
and to
arguments. to
by default is set as
WGS 84/EPSG:4326 (+proj=longlat +datum=WGS84
).
Tibble.
Stuart K. Grange
sp_transform
, sp_from_data_frame
## Not run:
# 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()
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.