Converts WGS84 longitude/latitude columns to an explicitly selected projected coordinate reference system. Spatial mesh models use metric planar distances; this helper deliberately does not infer a UTM zone or treat decimal degrees as planar coordinates.
Arguments
- data
A non-empty data frame containing the longitude and latitude columns.
- longitude, latitude
Unquoted or quoted names of the longitude and latitude columns, respectively.
- crs_out
A projected output CRS understood by
sf::st_crs(), for example32610or"EPSG:32610".
Value
A two-column numeric matrix with class drmTMB_coords. Its crs
attribute records the projected CRS and it can be supplied to make_mesh().
Examples
if (requireNamespace("sf", quietly = TRUE)) {
locations <- data.frame(lon = c(-123.2, -123.1), lat = c(49.2, 49.3))
spatial_coords(locations, lon, lat, crs_out = 32610)
}
#> x y
#> 1 485430.2 5449708
#> 2 492729.8 5460811
#> attr(,"crs")
#> Coordinate Reference System:
#> User input: EPSG:32610
#> wkt:
#> PROJCRS["WGS 84 / UTM zone 10N",
#> BASEGEOGCRS["WGS 84",
#> ENSEMBLE["World Geodetic System 1984 ensemble",
#> MEMBER["World Geodetic System 1984 (Transit)"],
#> MEMBER["World Geodetic System 1984 (G730)"],
#> MEMBER["World Geodetic System 1984 (G873)"],
#> MEMBER["World Geodetic System 1984 (G1150)"],
#> MEMBER["World Geodetic System 1984 (G1674)"],
#> MEMBER["World Geodetic System 1984 (G1762)"],
#> MEMBER["World Geodetic System 1984 (G2139)"],
#> ELLIPSOID["WGS 84",6378137,298.257223563,
#> LENGTHUNIT["metre",1]],
#> ENSEMBLEACCURACY[2.0]],
#> PRIMEM["Greenwich",0,
#> ANGLEUNIT["degree",0.0174532925199433]],
#> ID["EPSG",4326]],
#> CONVERSION["UTM zone 10N",
#> METHOD["Transverse Mercator",
#> ID["EPSG",9807]],
#> PARAMETER["Latitude of natural origin",0,
#> ANGLEUNIT["degree",0.0174532925199433],
#> ID["EPSG",8801]],
#> PARAMETER["Longitude of natural origin",-123,
#> ANGLEUNIT["degree",0.0174532925199433],
#> ID["EPSG",8802]],
#> PARAMETER["Scale factor at natural origin",0.9996,
#> SCALEUNIT["unity",1],
#> ID["EPSG",8805]],
#> PARAMETER["False easting",500000,
#> LENGTHUNIT["metre",1],
#> ID["EPSG",8806]],
#> PARAMETER["False northing",0,
#> LENGTHUNIT["metre",1],
#> ID["EPSG",8807]]],
#> CS[Cartesian,2],
#> AXIS["(E)",east,
#> ORDER[1],
#> LENGTHUNIT["metre",1]],
#> AXIS["(N)",north,
#> ORDER[2],
#> LENGTHUNIT["metre",1]],
#> USAGE[
#> SCOPE["Navigation and medium accuracy spatial referencing."],
#> AREA["Between 126°W and 120°W, northern hemisphere between equator and 84°N, onshore and offshore. Canada - British Columbia (BC); Northwest Territories (NWT); Nunavut; Yukon. United States (USA) - Alaska (AK)."],
#> BBOX[0,-126,84,-120]],
#> ID["EPSG",32610]]
#> attr(,"xy_cols")
#> [1] "x" "y"
#> attr(,"class")
#> [1] "drmTMB_coords" "matrix" "array"