add_utm_columns | R Documentation |
Add UTM (Universal Transverse Mercator) coordinates to a data frame. This is
useful since geostatistical modeling should generally be performed in an
equal-distance projection. You can do this yourself separately with the
sf::st_as_sf()
, sf::st_transform()
, and sf::st_coordinates()
functions
in the sf package.
add_utm_columns(
dat,
ll_names = c("longitude", "latitude"),
ll_crs = 4326,
utm_names = c("X", "Y"),
utm_crs = get_crs(dat, ll_names),
units = c("km", "m")
)
get_crs(dat, ll_names = c("longitude", "latitude"))
dat |
Data frame that contains longitude and latitude columns. |
ll_names |
Longitude and latitude column names. Note the order. |
ll_crs |
Input CRS value for |
utm_names |
Output column names for the UTM columns. |
utm_crs |
Output CRS value for the UTM zone; tries to detect with
|
units |
UTM units. |
Note that longitudes west of the prime meridian should be encoded as running from -180 to 0 degrees.
You may wish to work in km's rather than the standard UTM meters so that the range parameter estimate is not too small, which can cause computational issues. This depends on the the scale of your data.
A copy of the input data frame with new columns for UTM coordinates.
d <- data.frame(lat = c(52.1, 53.4), lon = c(-130.0, -131.4))
get_crs(d, c("lon", "lat"))
add_utm_columns(d, c("lon", "lat"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.