latlon2epsg: Transform Spatial Data to a Local UTM Coordinate System
Description
The `latlon2epsg` function determines the appropriate UTM (Universal Transverse Mercator) EPSG code for a given `sf` object
based on its centroid's latitude and longitude. It then transforms the object to the identified coordinate reference system (CRS).
Usage
latlon2epsg(sf_obj)
Value
An `sf` object transformed to the appropriate UTM coordinate reference system.
Arguments
sf_obj
An `sf` object representing spatial features. This object must have a valid CRS with latitude and longitude coordinates.
Details
The function calculates the geographic centroid of the input spatial object and determines its latitude and longitude.
Based on the latitude:
Latitudes above 84°
The object is transformed to EPSG:3413 (North Pole).
Latitudes below -80°
The object is transformed to EPSG:3031 (South Pole).
Latitudes between -80° and 84°
The function calculates the UTM zone based on longitude and transforms the object
to the appropriate UTM EPSG code (EPSG:326XX for the Northern Hemisphere, EPSG:327XX for the Southern Hemisphere).