project_on_AB: A function to project data on a line defined by two points A...

View source: R/project_on_AB.R

project_on_ABR Documentation

A function to project data on a line defined by two points A & B

Description

A function to project data on a line defined by two points A & B

Usage

project_on_AB(dat, datAB, datOg = datAB[1, ])

Arguments

dat

tibble with coordinates columns x and y

datAB

tibble with two rows (points A and B) and coordinates columns x and y

datOg

point that defines the origin (point with l=0) of the series

Value

xp x coordinate of points projected on the transect

yp y coordinate of points projected on the transect

xt x coordinate along the transect (new coordinate x)

yt y coordinate corresponding to the distance to the transect (new coordinate y)

Examples

dat=tibble(x=c(866142.3, 866149.9, 866143.7),
           y=c(84496.97, 84496.93, 84498.50))
datAB=tibble(x=c(866141.3,866148.7),
             y=c(84498.97, 84496.50))
dat=project_on_AB(dat,datAB)
ggplot(dat,  aes(x=x,y=y))+
  geom_point(col="red")+
  geom_line(data=datAB, aes(x=x,y=y))+
  geom_point(data=datAB)+
  geom_point(data=dat,col="blue", aes(x=xp,y=yp))+
  coord_fixed(ratio=1)

lvaudor/riverbed documentation built on Feb. 25, 2023, 3:47 p.m.