invoke.metric: Perform Geometric Task using a Specified Metric

View source: R/distancemetrics.R

invoke.metricR Documentation

Perform Geometric Task using a Specified Metric

Description

Perform a desired geometrical operation using a specified distance metric.

Usage

  invoke.metric(m, task, ..., evaluate=TRUE)

Arguments

m

Metric (object of class "metric")

task

Character string specifying the task. The name of a function that performs the desired operation for the Euclidean metric.

...

Input to the function that performs the geometrical operation (matching the arguments of task).

evaluate

Logical value specifying whether to actually perform the computation and return the result (evaluate=TRUE, the default) or to simply return the function which performs the computation (evaluate=FALSE).

Details

A ‘metric’ is a measure of distance between points in space. An object of class "metric" represents such a metric, and supports many geometrical computations that involve the metric. See metric.object.

The argument task should be the name of an existing function in the spatstat family representing a geometrical operation, such as computing pairwise distances, nearest-neighbour distances, the distance map, and so on. The code will determine whether this geometrical operation has a counterpart using the specified metric, that is defined and supported in the object m. If so, then this operation will be applied to the data specified in ..., and the result will be returned.

For example, the spatstat function nndist.ppp computes nearest-neighbour distances using the Euclidean distance metric. To calculate nearest-neighbour distances for a point pattern X using another metric m, use invoke.metric(m, "nndist.ppp", X).

If evaluate=FALSE, the computation is not performed, and invoke.metric simply returns a function to perform the desired operation.

Value

If evaluate=TRUE (the default), the result of the computation has the same format as the result of the computation using the existing function named task.

If evaluate=FALSE, the result is a function in the R language to perform the desired operation; or NULL if the operation is not supported by the metric.

Author(s)

\adrian

.

See Also

convexmetric

Examples

  ## nearest-neighbour distances using rectangular metric (L^1 metric)
  d <- convexmetric(square(c(-1,1)))
  y <- invoke.metric(d, "nndist.ppp", cells)
  f <- invoke.metric(d, "nndist.ppp", cells, evaluate=FALSE)
  y <- f(cells)
  invoke.metric(d, "orderPizza", evaluate=FALSE)

spatstat.geom documentation built on Sept. 18, 2024, 9:08 a.m.