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

coordinates

set spatial coordinates to create a Spatial object, or retrieve spatial coordinates from a Spatial object


Description

set spatial coordinates to create a Spatial object, or retrieve spatial coordinates from a Spatial object

Usage

coordinates(obj, ...)
	coordinates(object) <- value

Arguments

obj

object deriving from class "Spatial"

object

object of class "data.frame"

value

spatial coordinates; either a matrix, list, or data frame with numeric data, or column names, column number or a reference: a formula (in the form of e.g. ~x+y), column numbers (e.g. c(1,2)) or column names (e.g. c("x","y")) specifying which columns in object are the spatial coordinates. If the coordinates are part of object, giving the reference does not duplicate them, giving their value does duplicate them in the resulting structure.

...

additional arguments that may be used by particular methods

Value

usually an object of class SpatialPointsDataFrame; if the coordinates set cover the full set of variables in object, an object of class SpatialPoints is returned

Examples

# data.frame
data(meuse.grid)
coordinates(meuse.grid) <- ~x+y
gridded(meuse.grid) <- TRUE
class(meuse.grid)
bbox(meuse.grid)

data(meuse)
meuse.xy = meuse[c("x", "y")]
coordinates(meuse.xy) <- ~x+y
class(meuse.xy)

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.