lnglat_to_xy: Convert between WGS84 and Web Mercator Coordinates

View source: R/clusters.R

lnglat_to_xyR Documentation

Convert between WGS84 and Web Mercator Coordinates

Description

Converts between geographic WGS84 (EPSG:4326) coordinates in decimal degrees and projected Web Mercator (EPSG:3857) coordinates in meters.

Usage

lnglat_to_xy(lnglat)

xy_to_lnglat(xy)

Arguments

lnglat

Rows of coordinates in decimal degrees (longitude, latitude), with longitude: [-180, 180) and latitude: [-85.05112, 85.05112].

xy

Rows of Web Mercator coordinates in meters (x, y).

Examples

lng <- c(-45, -45, 45, 45)
lat <- c(-45, 45, 45, -45)
lnglat <- cbind(lng, lat)
xy_to_lnglat(lnglat_to_xy(lnglat)) - lnglat

falling-fruit/fruitr documentation built on Dec. 21, 2024, 8:32 p.m.