Learn R Programming

phylin (version 2.0.2)

midpoints: Midpoints between pairs of coordinates

Description

Computes the midpoints for a table of sample points with coordinates.

Usage

midpoints(samples, x=1, y=2, sp.name=row.names(samples), all=FALSE)

Arguments

samples

Table with coordinates for each sample point.

x

Column index or name of longitudes (x) in samples table (default is first column).

y

Column index or name of latitudes (y) in samples table (default is second column).

sp.name

Name for each sample point (defaults to row names of samples).

all

If TRUE computes midpoints between all sample points. If FALSE (default) computes a Delaunay triangulation and the midpoints of the resulting connected samples.

Value

Returns a data frame with 4 columns referring the source and target samples (ss and ts, respectively) and the coordinates of the midpoints.

Details

This function computes the coordinates of the middle points between samples. The connecting network can be between all points or between neighbours with non-overlaping edges after a Delaunay triangulation.

See Also

dist d.gen extract.val

Examples

Run this code
# NOT RUN {
data(vipers)
mp <- midpoints(vipers[,1:2], all=TRUE) 
# With 'all=FALSE' (Delaunay triang.), package 'geometry' is mandatory.

# }

Run the code above in your browser using DataLab