st_azimuth | R Documentation |
Computes the azimuths of two points. A set of geometries may be used.
st_azimuth(x, y, ..., unit = "rad")
## S3 method for class sfc_POINT and sf
st_azimuth(x, y, ..., unit = "rad")
## S3 method for class sfc_POINT, sfc_LINESTRING and sf
st_azimuth(x, y, ..., unit="rad", simplify=TRUE)
x |
If y is missing, and x is sfc_POINT compute the azimuths of two consecutive points. If y is missing and x is sfc_LINESTRING, assign a unique ID to each linestring; cast the linestring to POINT and then compute azimuth of consecutive points. If x is sf, compute azimuth of its geometry column. |
y |
If y is a sfc_POINT, then compute pairwise azimuth between x and y. |
... |
Additional arguments passed to |
unit |
Whether to convert the unit of azimuth e.g. to degree. |
simplify |
For sfc_LINESTRING |
If the CRS of x
is lat/lon, then lwgeom:st_geod_azimuth
is called and a geodetic azimuth is computed.
Farid Cheraghi mailto:faridcher@gmail.com
st_geod_azimuth
and atan2
x <- st_sfc(st_point(c(0,1)), st_point(c(1,1)))
st_azimuth(x)
# planar azimuth
st_azimuth(x[1:2], x[2:1], units="degree")
# geodetic azimuth
st_crs(x) <- 4326
st_azimuth(x[1:2], x[2:1], units="degree")
# sfc_LINESTRING
pts = matrix(1:6, , 2)
ls1 = st_linestring(pts)
st_azimuth(st_sfc(ls1,ls1))
# sf
st_azimuth(st_sf(g=st_sfc(ls1,ls1)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.