xyFrom2PointLine: Extraction of values of a line

View source: R/xyFrom2PointLine.R

xyFrom2PointLineR Documentation

Extraction of values of a line

Description

This function extract the values or the xy coordinate of a line passing through two points.

Usage

xyFrom2PointLine(
  r = NULL,
  points = data.frame(x = c(0, 1), y = c(0, 1)),
  step = NULL,
  radius = NA,
  angle = NA,
  units_angle = c("deg", "rad"),
  fun = NULL,
  ...
)

Arguments

r

a Raster* object

points

data frame containing x and y coordinaates from start and end point

step

step used for the extraction of the segment points

radius

length of the segment from the start point (optional)

angle

angle direction of the segment from the start point (optional). It is counterclockwise from East.

units_angle

string measurement unit angle. It is c("deg","rad")[1], i.e. deg is the default value.

fun

optional aggregation function. Default is NULL. If it not NULL the functions return a vector containing an atomic aggregate value for each raster layer.

...

further arguments for fun

Examples

xy_A <- xyFrom2PointLine(points=data.frame(x=c(0,1),y=c(0,1)),step=0.1)


dem <- raster(system.file("dem/dem_rendena.asc",package="horizons"))

xP <- (xmax(dem)*0.4+xmin(dem)*0.6)
yP <- (ymax(dem)*0.4+ymin(dem)*0.6)

xy_B <- xyFrom2PointLine(r=dem,points=data.frame(x=xP,y=yP),radius=10000,angle=35,units_angle="deg")

max_xy_B <- xyFrom2PointLine(r=dem,points=data.frame(x=xP,y=yP),radius=10000,angle=35,units_angle="deg",fun=max,na.rm=TRUE)
min_xy_B <- xyFrom2PointLine(r=dem,points=data.frame(x=xP,y=yP),radius=10000,angle=35,units_angle="deg",fun=min,na.rm=TRUE)


median_xy_B <- xyFrom2PointLine(r=dem,points=data.frame(x=xP,y=yP),radius=10000,angle=35,units_angle="deg",fun=median,na.rm=TRUE)
median_xy_BA <-  xyFrom2PointLine(r=brick(dem,dem+1),points=data.frame(x=xP,y=yP),radius=10000,angle=35,units_angle="deg",fun=median,na.rm=TRUE)



ecor/horizons documentation built on Jan. 4, 2024, 6:25 p.m.