Learn R Programming

spatstat.geom (version 2.3-1)

invoke.metric: 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).

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.

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.

See Also

convexmetric

Examples

Run this code
# NOT RUN {
  ## 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)
# }

Run the code above in your browser using DataLab