Skip to contents

Extract azimuths of line segments

Usage

line_azimuth(x)

lines_azimuths(x)

Arguments

x

sf object of type "LINESTRING" or "MULTILINESTRING"

Value

sf object of type "POINT" with the columns and entries of the first row of x

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. For MULTILINESTRING objects, use lines_azimuths().

Examples

data("plates")
subset(plates, pair == "af-eu") |>
  smoothr::densify() |>
  line_azimuth()
#> Warning: It is recommended to only use single line objects
#> Warning: repeating attributes for all sub-geometries for which they may not be constant
#> 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  275.6993 af-eu     af     eu convergent           in af-eu_convergent Africa
#> 2  275.6991 af-eu     af     eu convergent           in af-eu_convergent Africa
#> 3  275.6988 af-eu     af     eu convergent           in af-eu_convergent Africa
#> 4  275.6986 af-eu     af     eu convergent           in af-eu_convergent Africa
#> 5  275.6984 af-eu     af     eu convergent           in af-eu_convergent Africa
#> 6  275.6982 af-eu     af     eu convergent           in af-eu_convergent Africa
#> 7  275.6979 af-eu     af     eu convergent           in af-eu_convergent Africa
#> 8  275.6977 af-eu     af     eu convergent           in af-eu_convergent Africa
#> 9  275.6975 af-eu     af     eu convergent           in af-eu_convergent Africa
#> 10 275.6972 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)

if (FALSE) {
lines_azimuths(plates)
}