# Coordinate reference system

## Definition

“A […] coordinate reference system (CRS) is a coordinate-based local, regional or global system used to locate geographical entities. A spatial reference system defines a specific map projection, as well as transformations between different spatial reference systems. […] spatial reference systems can be referred to using a SRID integer, including EPSG codes …” (wikipedia.org, 2019).

The SRIDs and corresponding EPSG codes of all CRS can be found on spatialreference.org. The most common global CRS in latitude and longitude is WGS84 (used by the GPS satellite navigation system) with the following CRS string "+init=epsg:4326" as identifier.

## Transform CRS in 3-D

The eRTG3D only supports calculations in Cartesian coordinate systems. In case of latitude / longitude data (e.g.: WGS84), these must be converted into a Cartesian coordinate system, as for example the Universal Transverse Mercator (UTM).

head(track.wgs84)
#>          x        y        z
#> 1 6.868026 46.84473 1283.736
#> 2 6.895325 46.85352 1359.580
#> 3 6.920342 46.85870 1369.713
#> 4 6.945902 46.86607 1391.752
#> 5 6.963975 46.86605 1806.566
#> 6 7.017997 46.88671 1764.062

To carry out a CRS transformation, please use transformCRS.3d(), which is based on the st_transform() from the sf package. Therefore is supports CRS transformations in 3-D.

track <- transformCRS.3d(track.wgs84, fromCRS=4326, toCRS=2056)
#>         x       y        z            a        g           t            l
#> 1 2556476 1188336 1283.736  0.391476625 1.557032          NA           NA
#> 2 2558565 1189297 1359.580  0.431339520 1.537826  0.03986289 -0.019205136
#> 3 2560477 1189861 1369.713  0.286613422 1.565712 -0.14472610  0.027885542
#> 4 2562431 1190668 1391.752  0.391695363 1.560373  0.10508194 -0.005338766
#> 5 2563809 1190657 1806.566 -0.008350379 1.278403 -0.40004574 -0.281969986
#> 6 2567940 1192930 1764.062  0.503007060 1.579810  0.51135744  0.301406799
#>          d
#> 1       NA
#> 2 2300.818
#> 3 1993.003
#> 4 2114.493
#> 5 1439.106
#> 6 4715.520

Note: spTransform() from the sp package only supports transformations in the 2-D plane, which will cause distortions in the third dimension.