Learn R Programming

sp (version 0.9-78)

SpatialPointsDataFrame-class: Class "SpatialPointsDataFrame"

Description

Class for spatial attributes that have spatial point locations

Usage

## S3 method for class 'SpatialPointsDataFrame':
[(x, i, j, ..., drop = TRUE)
  ## S3 method for class 'SpatialPointsDataFrame,SpatialPoints':
coerce(from, to, strict=TRUE)
  ## S3 method for class 'SpatialPointsDataFrame,data.frame':
coerce(from, to, strict=TRUE)
  ## S3 method for class 'SpatialPointsDataFrame':
coordinates(obj)
  ## S3 method for class 'SpatialPointsDataFrame':
show(object)
  ## S3 method for class 'SpatialPointsDataFrame':
points(x)
  ## S3 method for class 'SpatialPointsDataFrame':
rbind(...)

Arguments

x,from,obj,object
SpatialPointsDataFrame object
to
class to which to coerce
strict
see as
i
row indices
j
column indices
drop
...
indices passed through

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.

Extends

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

See Also

coordinates, SpatialPoints-class

Examples

Run this code
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)

Run the code above in your browser using DataLab