st_azimuth: Planar and geodetic azimuth of two points

View source: R/st_azimuth.r

st_azimuthR Documentation

Planar and geodetic azimuth of two points

Description

Computes the azimuths of two points. A set of geometries may be used.

Usage

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)

Arguments

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 st_geod_azimuth

unit

Whether to convert the unit of azimuth e.g. to degree.

simplify

For sfc_LINESTRING x, whether to simplify azimuth vector.

Details

If the CRS of x is lat/lon, then lwgeom:st_geod_azimuth is called and a geodetic azimuth is computed.

Author(s)

Farid Cheraghi mailto:faridcher@gmail.com

See Also

st_geod_azimuth and atan2

Examples

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)))

faridcher/futils documentation built on Nov. 2, 2024, 10:37 a.m.