utm_zone: UTM zone based on geographic location(s)

View source: R/crs.R

utm_zoneR Documentation

UTM zone based on geographic location(s)

Description

The function determines the UTM number and south/north location for the mid-point of x.

Usage

utm_zone(x, crs = 4326)

Arguments

x

A numerical two-dimensional object (a matrix, array, or data.frame) with longitude/X, latitude/Y as columns; a sp::SpatialPoints object; or a terra::SpatVector object; or a sf object with a point geometry, i.e., an object with a class sf or sfc.

crs

An object which is a crs or from which one can be derived. x can be numeric as a EPSG number; a character string as a wkt; a character string as a proj4 (not recommended because outdated); or of a class including raster::Raster, sp::Spatial, sp::CRS, or a sf or sfc class.

Value

A list with two elements:

utm_zone

The UTM zone number as integer value.

utm_NS

North/South indicator as character "N" or "S"

.

References

Convert Latitude/Longitude to UTM https://www.wavemetrics.com/code-snippet/convert-latitudelongitude-utm (attributed to Chuck Gantz).

Examples

locations <- matrix(
  data = c(-120.325, -111.245, 39.855, 36.753),
  nrow = 2
)

utm_zone(locations)
utm_zone(locations[1, ])
utm_zone(locations[2, ])


DrylandEcology/rSW2st documentation built on Jan. 10, 2024, 6:22 p.m.