SpatialPointsDataFrame-class {sp} | R Documentation

## Class "SpatialPointsDataFrame"

### Description

Class for spatial attributes that have spatial point locations

### Objects from the Class

Objects can be created by calls of the form `coordinates(x) = c("x", "y")` . or of the form `coordinates(x) = xy`; see coordinates.

### Slots

`data`:
  Object of class AttributeList-class containing the attribute data (may or may not contain the coordinates in its columns)
`coords`:
  Object of class `"matrix"`; the coordinates matrix (points are rows in the matrix)
`coords.stripped`
  Object of class logical; if TRUE, when the object was created the coordinates were retrieved from the data.frame, and hence stripped from it; after coercion to data.frame, e.g. by as.data.frame(x), coordinates will again be added (as first few columns) to the data.frame
`bbox`:
  Object of class `"matrix"`; bounding box
`proj4string`:
  Object of class `"CRS"`; projection string

### Extends

Class `"SpatialPoints"`, directly. Class `"Spatial"`, by class `"SpatialPoints"`.

### Methods

[
  `signature(x = "SpatialPointsDataFrame")`: subset rows or columns; in case of row subsetting, the coordinates are also subsetted
coerce
  `signature(from = "SpatialPointsDataFrame", to = "data.frame")`: extracts the AttributeList part, and converts it to a data.frame
coerce
  `signature(from = "SpatialPointsDataFrame", to = "AttributeList")`: extracts the AttributeList part
coordinates
  `signature(obj = "SpatialPointsDataFrame")`: retrieves the coordinates only
show
  `signature(object = "SpatialPointsDataFrame")`: print method
plot
  `signature(x = "SpatialPointsDataFrame")`: plot points
points
  `signature(x = "SpatialPointsDataFrame")`: add points to plot

### Note

### Author(s)

Edzer J. Pebesma, e.pebesma@geo.uu.nl

### References

### See Also

`coordinates`, `SpatialPoints-class`

### Examples

    data(meuse)
    xy = meuse[c("x", "y")] # retrieve coordinates as data.frame
    class(meuse)
    data(meuse) # reload data.frame
    coordinates(meuse) = c("x", "y") # specify column names
    class(meuse)
    data(meuse) # reload data.frame
    coordinates(meuse) = c(1, 2) # specify column names
    class(meuse)
    data(meuse) # reload data.frame
    coordinates(meuse) = ~x+y # formula
    class(meuse)
    data(meuse) # reload data.frame
    coordinates(meuse) = xy   # as data frame
    class(meuse)
    data(meuse) # reload data.frame
    coordinates(meuse) = as.matrix(xy)   # as matrix
    meuse$log.zn = log(meuse$zinc)
    class(meuse)
    dim(meuse)

[Package sp version 0.7-12 Index]