Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

SpatialPointsDataFrame-class

Class "SpatialPointsDataFrame"


Description

Class for spatial attributes that have spatial point locations

Usage

## S4 method for signature 'SpatialPointsDataFrame'
x[i, j, ..., drop = TRUE]
  ## S4 method for signature 'SpatialPointsDataFrame,SpatialPoints'
coerce(from, to, strict=TRUE)
  ## S4 method for signature 'SpatialPointsDataFrame,data.frame'
coerce(from, to, strict=TRUE)
  ## S4 method for signature 'SpatialPointsDataFrame'
coordinates(obj)
  ## S4 method for signature 'SpatialPointsDataFrame'
show(object)
  ## S4 method for signature '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

see Extract

...

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.

Slots

data:

Object of class data.frame 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.nrs

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".

Author(s)

See Also

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)

sp

Classes and Methods for Spatial Data

v1.4-5
GPL (>= 2)
Authors
Edzer Pebesma [aut, cre], Roger Bivand [aut], Barry Rowlingson [ctb], Virgilio Gomez-Rubio [ctb], Robert Hijmans [ctb], Michael Sumner [ctb], Don MacQueen [ctb], Jim Lemon [ctb], Finn Lindgren [ctb], Josh O'Brien [ctb], Joseph O'Rourke [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.