utm_select: Automatically convert geographic (degree) to planar...

View source: R/utm_select.R

utm_selectR Documentation

Automatically convert geographic (degree) to planar coordinates (meters)

Description

Function to automatically convert simple feature, spatial and raster objects with geographic coordinates (longitude, latitude / WGS 1984, EPSG:4326) to planar UTM coordinates. If the study region spans multiple UTM zones, defaults to Albers Equal Area.

Usage

utm_select(x, max_zones = 5, return_list = FALSE)

Arguments

x

Layer to be reprojected. sf, sp, SpatRaster or RasterLayer object.

max_zones

Maximum number of UTM zones for single layer. Default is 5. Numeric.

return_list

Return list object instead of reprojected layer (see Details). Default is FALSE. Logical.

Details

Optimal map projection for the object x is defined by matching its horizontal extent with that of the 60 UTM zones. If object spans multiple UTM zones, uses either the median zone (if number of zones is equal to or less than max_zones) or Albers Equal Area projection with median longitude as projection center (if number of zones is greater than max_zones).

Value

Re-projected layer. sf or RasterLayer object, depending on input.

If return_list=TRUE, returns a list object containing

  • "x_out". The re-projected layer. sf or RasterLayer object, depending on input.

  • "proj4_best".proj4string of the projection. Character string.

Examples

# Find a planar projection for an unprojected (WSG 1984) hexagonal grid of Germany
## Not run: 
data(hex_05_deu)
out_1 <- utm_select(hex_05_deu)

## End(Not run)
# Find a planar projection for a raster
## Not run: 
data(gpw4_deu2010)
out_2 <- utm_select(gpw4_deu2010)

## End(Not run)

zhukovyuri/SUNGEO documentation built on Nov. 5, 2023, 1:07 p.m.