This function was designed to find lines that are close to parallel and perpendicular to some pre-defined route. It can return results that are absolute (contain information on the direction of turn, i.e. + or - values for clockwise/anticlockwise), bidirectional (which mean values greater than +/- 90 are impossible).
angle_diff(l, angle, bidirectional = FALSE, absolute = TRUE)
A spatial lines object
an angle in degrees relative to North, with 90 being East and -90 being West. (direction of rotation is ignored).
Should the result be returned in a bidirectional format? Default is FALSE. If TRUE, the same line in the oposite direction would have the same bearing
If TRUE (the default) only positive values can be returned
Building on the convention used in bearing()
and in many applications,
North is definied as 0, East as 90 and West as -90.
Other lines: geo_toptail
,
is_linepoint
, line2df
,
line_bearing
, line_match
,
line_midpoint
, line_sample
,
line_segment
, line_via
,
mats2line
, n_sample_length
,
n_vertices
, onewaygeo
,
onewayid
, points2line
,
toptail_buff
, toptailgs
,
update_line_geometry
# NOT RUN {
# Find all routes going North-South
a <- angle_diff(flowlines, angle = 0, bidirectional = TRUE, absolute = TRUE)
plot(flowlines)
plot(flowlines[a < 15, ], add = TRUE, lwd = 3, col = "red")
# East-West
plot(flowlines[a > 75, ], add = TRUE, lwd = 3, col = "green")
angle_diff(flowlines_sf[2, ], angle = 0)
# }
Run the code above in your browser using DataLab