Extract azimuths of line segments
Details
It is recommended to perform line_azimuth()
on single line objects, i.e.
type "LINESTRING"
, instead of "MULTILINESTRING"
. This is because the azimuth
of the last point of a line will be calculated to the first point of the
next line otherwise. This will cause a warning message (if warn = TRUE
).
For "MULTILINESTRING"
objects, use lines_azimuths()
.
Examples
data("plates")
# one line:
subset(plates, pair == "af-eu") |>
smoothr::densify() |>
line_azimuth()
#> Warning: MULTILINESTRING object is not recommended
#> Simple feature collection with 1861 features and 9 fields
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: -29.7698 ymin: 33.985 xmax: 20.3001 ymax: 39.412
#> Geodetic CRS: WGS 84
#> First 10 features:
#> azi pair plateA plateB type displacement name nameA
#> 1 95.69929 af-eu af eu convergent in af-eu_convergent Africa
#> 2 95.69906 af-eu af eu convergent in af-eu_convergent Africa
#> 3 95.69883 af-eu af eu convergent in af-eu_convergent Africa
#> 4 95.69861 af-eu af eu convergent in af-eu_convergent Africa
#> 5 95.69838 af-eu af eu convergent in af-eu_convergent Africa
#> 6 95.69815 af-eu af eu convergent in af-eu_convergent Africa
#> 7 95.69793 af-eu af eu convergent in af-eu_convergent Africa
#> 8 95.69770 af-eu af eu convergent in af-eu_convergent Africa
#> 9 95.69747 af-eu af eu convergent in af-eu_convergent Africa
#> 10 95.69725 af-eu af eu convergent in af-eu_convergent Africa
#> nameB geometry
#> 1 Eurasia POINT (-5.80797 34.0191)
#> 2 Eurasia POINT (-5.766831 34.01569)
#> 3 Eurasia POINT (-5.725692 34.01228)
#> 4 Eurasia POINT (-5.684553 34.00887)
#> 5 Eurasia POINT (-5.643414 34.00546)
#> 6 Eurasia POINT (-5.602275 34.00205)
#> 7 Eurasia POINT (-5.561136 33.99864)
#> 8 Eurasia POINT (-5.519997 33.99523)
#> 9 Eurasia POINT (-5.478858 33.99182)
#> 10 Eurasia POINT (-5.437719 33.98841)
# multiple lines:
lines_azimuths(plates[1:5, ])
#> Simple feature collection with 150 features and 9 fields
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: -0.4379 ymin: -54.8518 xmax: 42.0332 ymax: 37.8039
#> Geodetic CRS: WGS 84
#> First 10 features:
#> azi pair plateA plateB type displacement name
#> 1.1 52.98880 af-an af an divergent out af-an_divergent
#> 1.2 51.23433 af-an af an divergent out af-an_divergent
#> 1.3 141.83793 af-an af an divergent out af-an_divergent
#> 1.4 44.60702 af-an af an divergent out af-an_divergent
#> 1.5 47.34529 af-an af an divergent out af-an_divergent
#> 1.6 45.71276 af-an af an divergent out af-an_divergent
#> 1.7 132.21165 af-an af an divergent out af-an_divergent
#> 1.8 130.50217 af-an af an divergent out af-an_divergent
#> 1.9 138.80081 af-an af an divergent out af-an_divergent
#> 1.10 41.99286 af-an af an divergent out af-an_divergent
#> nameA nameB geometry
#> 1.1 Africa Antarctica POINT (-0.4379 -54.8518)
#> 1.2 Africa Antarctica POINT (-0.0388257 -54.6772)
#> 1.3 Africa Antarctica POINT (0.443182 -54.4512)
#> 1.4 Africa Antarctica POINT (0.964534 -54.8322)
#> 1.5 Africa Antarctica POINT (1.69481 -54.399)
#> 1.6 Africa Antarctica POINT (2.35975 -54.0374)
#> 1.7 Africa Antarctica POINT (3.02542 -53.6507)
#> 1.8 Africa Antarctica POINT (3.36894 -53.8341)
#> 1.9 Africa Antarctica POINT (3.95638 -54.1267)
#> 1.10 Africa Antarctica POINT (4.41458 -54.4303)