View source: R/create_xy_from_lonlat.R
| create_xy_from_lonlat | R Documentation |
This function converts geographic coordinates (lon, lat)
into planar coordinates (x, y)
using an automatically selected UTM projection.
create_xy_from_lonlat(df)
df |
A data.frame containing geographic coordinates ( |
The input data.frame must contain geographic coordinates (lon and lat).
Planar coordinates (x, y) are automatically computed using the
UTM zone inferred from the mean longitude and hemisphere inferred from the mean latitude.
A list with the following elements:
dfThe input data.frame with added x and y columns (meters, UTM).
epsgEPSG code of the UTM projection used.
# Example data with longitude / latitude (WGS84)
df <- data.frame(
lon = c(4.35, 4.36),
lat = c(50.85, 50.86)
)
# Convert to planar coordinates (UTM)
res <- create_xy_from_lonlat(df)
# Access results
res$df # data.frame with x, y columns
res$epsg # EPSG code used
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.