R: Distance Metric Defined by Convex Set

convexmetric {spatstat.geom} | R Documentation

## Distance Metric Defined by Convex Set

### Description

Create the distance metric associated with a given convex polygon.

### Usage

    convexmetric(K)

### Arguments

`K` | Convex set defining the metric. A polygon that is symmetric about the origin. See Details.

### Details

This function creates the distance metric associated with the convex set `K` so that the unit ball of the metric is equal to `K`. It returns an object of class `"metric"` representing the metric (see `metric.object`).

The argument `K` must be a window (class `"owin"`). It will be converted to a polygon. It must be convex, and symmetric about the origin.

To perform distance calculations (for example, nearest-neighbour distances) using this metric instead of the Euclidean metric, first check whether the standard function for this purpose (for example `nndist.ppp`) has an argument named `metric`. If so, use the standard function and add the argument `metric`; if not, use the low-level function `invoke.metric`.

To see which operations are currently supported by the metric, use `summary`, as shown in the examples.

### Value

An object of class `"metric"`.

### Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au

### See Also

`metric.object`, `invoke.metric`

### Examples

      K <- owin(poly=list(x=c(2.5,2,0.5,-2.5,-2,-0.5),y=c(0,1,2,0,-1,-2)))
      plot(K)
      points(0,0)
      m <- convexmetric(K)
      m
      summary(m)

      ## show redwood data and identify point number 43
      plot(redwood, main="")
      plot(redwood[43], pch=16, add=TRUE)

      ## compute nearest neighbour distances and identifiers
      ##   using the distance metric m
      nd <- nndist(redwood, metric=m)
      nw <- nnwhich(redwood, metric=m)

      ## Nearest neighbour distance for point number 43 is nd[43]; verify
      B43 <- disc(radius=nd[43], centre=redwood[43], metric=m)
      plot(B43, add=TRUE)

      ## nearest neighbour for point number 43 is point number nw[43]; verify
      plot(redwood[nw[43]], pch=3, col="red", add=TRUE)

[Package spatstat.geom version 2.3-2 Index]