Skip to contents

Extract azimuths of line segments

Usage

line_azimuth(x, warn = TRUE)

lines_azimuths(x)

Arguments

x

sf object of type "LINESTRING" or "MULTILINESTRING"

warn

logical; if TRUE, warn if "MULTILINESTRING" (default).

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 (if warn = TRUE). For "MULTILINESTRING" objects, use lines_azimuths().

Examples

data("plates")
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)

if (FALSE) { # \dontrun{
lines_azimuths(plates)
} # }