area: Compute area of a polygon

Description Usage Arguments Value Examples

View source: R/getbuds.R

Description

This function computes the area of a polygon X.

Usage

1
area(X)

Arguments

X

a polygon dataframe of x and y coordinates

Value

area of the polygon x.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
filename<-system.file('data/YET629_02_w1L488nm-L561nm_sequence-10000.zip', package='yeast')
roi <- read.ijzip(filename)

cordi <- roi$`001_001`$coords
X <-  data.frame(X=cordi[,1], Y=cordi[,2])
area<-function(X){
 X<-cbind(X$X, X$Y)
 X<-rbind(X,X[1,])
 x<-X[,1]; y<-X[,2]; lx<-length(x)
 -sum((x[2:lx]-x[1:lx-1])*(y[2:lx]+y[1:lx-1]))/2
}

area(X)

maekiniemi/yeastTracker documentation built on June 9, 2020, 1:40 p.m.