Learn R Programming

SpatialVx (version 1.0-2)

centdist: Centroid Distance Between Two Identified Objects

Description

Find the centroid distance between two identified objects/features.

Usage

centdist(x, y, distfun = "rdist", loc = NULL, ...)

Value

numeric giving the centroid distance.

Arguments

x,y

objects of class “owin” (package spatstat) containing binary images of features of interest.

distfun

character string naming a distance function that should take arguments x1 and x2 as 1 by 2 matrices, and return a single numeric value. Default uses the fields function, rdist, where the fields function rdist.earth is an obvious alternative.

loc

two-column matrix giving the location values for which to calculate the centroids. If NULL, indices according to the dimension of the fields are used.

...

optional arguments to distfun.

Author

Eric Gilleland

Details

This is a simple function that calculates the centroid for each of x and y (to get their centroids), and then finds the distance between them according to distfun. The centroids are calculated using FeatureProps.

See Also

FeatureProps, as.im, solutionset, FeatureMatchAnalyzer, FeatureComps

Examples

Run this code
x <- y <- matrix(0, 10, 12)
x[2:3,c(3:6, 8:10)] <- 1
y[c(4:7, 9:10),c(7:9, 11:12)] <- 1

x <- as.im(x)
x <- solutionset(x>0)
y <- as.im(y)
y <- solutionset(y>0)
centdist(x,y)

Run the code above in your browser using DataLab