create_xy_from_lonlat: Create planar (x, y) coordinates from longitude / latitude

View source: R/create_xy_from_lonlat.R

create_xy_from_lonlatR Documentation

Create planar (x, y) coordinates from longitude / latitude

Description

This function converts geographic coordinates (lon, lat) into planar coordinates (x, y) using an automatically selected UTM projection.

Usage

create_xy_from_lonlat(df)

Arguments

df

A data.frame containing geographic coordinates (lon and lat).

Details

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.

Value

A list with the following elements:

df

The input data.frame with added x and y columns (meters, UTM).

epsg

EPSG code of the UTM projection used.

Examples

# 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


SamsaRaLight documentation built on April 16, 2026, 5:08 p.m.