# coords: Extract or Change Coordinates of a Spatial or Spatiotemporal... In spatstat: Spatial Point Pattern Analysis, Model-Fitting, Simulation, Tests

## Description

Given any kind of spatial or space-time point pattern, this function extracts the (space and/or time and/or local) coordinates of the points and returns them as a data frame.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10``` ``` coords(x, ...) ## S3 method for class 'ppp' coords(x, ...) ## S3 method for class 'ppx' coords(x, ..., spatial = TRUE, temporal = TRUE, local=TRUE) coords(x, ...) <- value ## S3 replacement method for class 'ppp' coords(x, ...) <- value ## S3 replacement method for class 'ppx' coords(x, ..., spatial = TRUE, temporal = TRUE, local=TRUE) <- value ```

## Arguments

 `x` A point pattern: either a two-dimensional point pattern (object of class `"ppp"`), a three-dimensional point pattern (object of class `"pp3"`), or a general multidimensional space-time point pattern (object of class `"ppx"`). `...` Further arguments passed to methods. `spatial,temporal,local` Logical values indicating whether to extract spatial, temporal and local coordinates, respectively. The default is to return all such coordinates. (Only relevant to `ppx` objects). `value` New values of the coordinates. A numeric vector with one entry for each point in `x`, or a numeric matrix or data frame with one row for each point in `x`.

## Details

The function `coords` extracts the coordinates from a point pattern. The function `coords<-` replaces the coordinates of the point pattern with new values.

Both functions `coords` and `coords<-` are generic, with methods for the classes `"ppp"`) and `"ppx"`. An object of class `"pp3"` also inherits from `"ppx"` and is handled by the method for `"ppx"`.

## Value

`coords` returns a `data.frame` with one row for each point, containing the coordinates. `coords<-` returns the altered point pattern.

## Author(s)

and \rolf

`ppx`, `pp3`, `ppp`, `as.hyperframe.ppx`, `as.data.frame.ppx`.

## Examples

 ```1 2 3 4 5``` ``` df <- data.frame(x=runif(4),y=runif(4),t=runif(4)) X <- ppx(data=df, coord.type=c("s","s","t")) coords(X) coords(X, temporal=FALSE) coords(X) <- matrix(runif(12), ncol=3) ```

### Example output

```Loading required package: nlme

spatstat 1.51-0       (nickname: 'Poetic Licence')
For an introduction to spatstat, type 'beginner'

x         y         t
1 0.2695188 0.7003367 0.1725720
2 0.1868056 0.1515384 0.8242227
3 0.9835246 0.5369187 0.8067443
4 0.9151121 0.5506091 0.7842845
x         y
1 0.2695188 0.7003367
2 0.1868056 0.1515384
3 0.9835246 0.5369187
4 0.9151121 0.5506091
```

spatstat documentation built on April 5, 2018, 5:04 p.m.