Class for spatial attributes that have spatial point locations

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

See also

Examples

data(meuse) xy = meuse[c("x", "y")] # retrieve coordinates as data.frame class(meuse)
#> [1] "data.frame"
data(meuse) # reload data.frame coordinates(meuse) = c("x", "y") # specify column names class(meuse)
#> [1] "SpatialPointsDataFrame" #> attr(,"package") #> [1] "sp"
data(meuse) # reload data.frame coordinates(meuse) = c(1, 2) # specify column names
#> Error in `coordinates<-`(`*tmp*`, value = c(1, 2)): setting coordinates cannot be done on Spatial objects, where they have already been set
class(meuse)
#> [1] "SpatialPointsDataFrame" #> attr(,"package") #> [1] "sp"
data(meuse) # reload data.frame coordinates(meuse) = ~x+y # formula
#> Error in `coordinates<-`(`*tmp*`, value = ~x + y): setting coordinates cannot be done on Spatial objects, where they have already been set
class(meuse)
#> [1] "SpatialPointsDataFrame" #> attr(,"package") #> [1] "sp"
data(meuse) # reload data.frame coordinates(meuse) = xy # as data frame
#> Error in `coordinates<-`(`*tmp*`, value = structure(list(x = c(181072, 181025, 181165, 181298, 181307, 181390, 181165, 181027, 181060, 181232, 181191, 181032, 180874, 180969, 181011, 180830, 180763, 180694, 180625, 180555, 180642, 180704, 180704, 181153, 181147, 181167, 181008, 180973, 180916, 181352, 181133, 180878, 180829, 180954, 180956, 180710, 180632, 180530, 180478, 180383, 180494, 180561, 180451, 180410, 180355, 180292, 180283, 180282, 180270, 180199, 180135, 180237, 180103, 179973, 179826, 179687, 179792, 179902, 180100, 179604, 179526, 179495, 179489, 179414, 179334, 179255, 179470, 179692, 179852, 179140, 179128, 179065, 179007, 179110, 179032, 179095, 179058, 178810, 178912, 178981, 179076, 180151, 179211, 181118, 179474, 179559, 179022, 178953, 178875, 178803, 179029, 178605, 178701, 179547, 179301, 179405, 179462, 179293, 179180, 179206, 179618, 179782, 179980, 180067, 180162, 180451, 180328, 180276, 180114, 179881, 179774, 179657, 179731, 179717, 179446, 179524, 179644, 180321, 180162, 180029, 179797, 179642, 179849, 180265, 180107, 180462, 180478, 180347, 180862, 180700, 180201, 180173, 180923, 180467, 179917, 179822, 179991, 179120, 179034, 179085, 179236, 179456, 179550, 179445, 179337, 179245, 179024, 178786, 179135, 179030, 179184, 179085, 178875, 179466, 180627), y = c(333611, 333558, 333537, 333484, 333330, 333260, 333370, 333363, 333231, 333168, 333115, 333031, 333339, 333252, 333161, 333246, 333104, 332972, 332847, 332707, 332708, 332717, 332664, 332925, 332823, 332778, 332777, 332687, 332753, 332946, 332570, 332489, 332450, 332399, 332318, 332330, 332445, 332538, 332578, 332476, 332330, 332193, 332175, 332031, 332299, 332157, 332014, 331861, 331707, 331591, 331552, 332351, 332297, 332255, 332217, 332161, 332035, 332113, 332213, 332059, 331936, 331770, 331633, 331494, 331366, 331264, 331125, 330933, 330801, 330955, 330867, 330864, 330727, 330758, 330645, 330636, 330510, 330666, 330779, 330924, 331005, 330353, 331175, 333214, 331304, 331423, 330873, 330742, 330516, 330349, 330394, 330406, 330557, 330245, 330179, 330567, 330766, 330797, 330710, 330398, 330458, 330540, 330773, 331185, 331387, 331473, 331158, 330963, 330803, 330912, 330921, 331150, 331245, 331441, 331422, 331565, 331730, 330366, 331837, 331720, 331919, 331955, 332142, 332297, 332101, 331947, 331822, 331700, 333116, 332882, 331160, 331923, 332874, 331694, 331325, 331242, 331069, 330578, 330561, 330433, 330046, 330072, 329940, 329807, 329870, 329714, 329733, 329822, 329890, 330082, 330182, 330292, 330311, 330381, 330190)), row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "69", "75", "76", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", "123", "160", "163", "70", "71", "91", "92", "93", "94", "95", "96", "97", "98", "99", "100", "101", "102", "103", "104", "105", "106", "108", "109", "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", "120", "121", "122", "124", "125", "126", "127", "128", "129", "130", "131", "132", "133", "134", "135", "136", "161", "162", "137", "138", "140", "141", "142", "143", "144", "145", "146", "147", "148", "149", "150", "151", "152", "153", "154", "155", "156", "157", "158", "159", "164"), class = "data.frame")): setting coordinates cannot be done on Spatial objects, where they have already been set
class(meuse)
#> [1] "SpatialPointsDataFrame" #> attr(,"package") #> [1] "sp"
data(meuse) # reload data.frame coordinates(meuse) = as.matrix(xy) # as matrix
#> Error in `coordinates<-`(`*tmp*`, value = structure(c(181072, 181025, 181165, 181298, 181307, 181390, 181165, 181027, 181060, 181232, 181191, 181032, 180874, 180969, 181011, 180830, 180763, 180694, 180625, 180555, 180642, 180704, 180704, 181153, 181147, 181167, 181008, 180973, 180916, 181352, 181133, 180878, 180829, 180954, 180956, 180710, 180632, 180530, 180478, 180383, 180494, 180561, 180451, 180410, 180355, 180292, 180283, 180282, 180270, 180199, 180135, 180237, 180103, 179973, 179826, 179687, 179792, 179902, 180100, 179604, 179526, 179495, 179489, 179414, 179334, 179255, 179470, 179692, 179852, 179140, 179128, 179065, 179007, 179110, 179032, 179095, 179058, 178810, 178912, 178981, 179076, 180151, 179211, 181118, 179474, 179559, 179022, 178953, 178875, 178803, 179029, 178605, 178701, 179547, 179301, 179405, 179462, 179293, 179180, 179206, 179618, 179782, 179980, 180067, 180162, 180451, 180328, 180276, 180114, 179881, 179774, 179657, 179731, 179717, 179446, 179524, 179644, 180321, 180162, 180029, 179797, 179642, 179849, 180265, 180107, 180462, 180478, 180347, 180862, 180700, 180201, 180173, 180923, 180467, 179917, 179822, 179991, 179120, 179034, 179085, 179236, 179456, 179550, 179445, 179337, 179245, 179024, 178786, 179135, 179030, 179184, 179085, 178875, 179466, 180627, 333611, 333558, 333537, 333484, 333330, 333260, 333370, 333363, 333231, 333168, 333115, 333031, 333339, 333252, 333161, 333246, 333104, 332972, 332847, 332707, 332708, 332717, 332664, 332925, 332823, 332778, 332777, 332687, 332753, 332946, 332570, 332489, 332450, 332399, 332318, 332330, 332445, 332538, 332578, 332476, 332330, 332193, 332175, 332031, 332299, 332157, 332014, 331861, 331707, 331591, 331552, 332351, 332297, 332255, 332217, 332161, 332035, 332113, 332213, 332059, 331936, 331770, 331633, 331494, 331366, 331264, 331125, 330933, 330801, 330955, 330867, 330864, 330727, 330758, 330645, 330636, 330510, 330666, 330779, 330924, 331005, 330353, 331175, 333214, 331304, 331423, 330873, 330742, 330516, 330349, 330394, 330406, 330557, 330245, 330179, 330567, 330766, 330797, 330710, 330398, 330458, 330540, 330773, 331185, 331387, 331473, 331158, 330963, 330803, 330912, 330921, 331150, 331245, 331441, 331422, 331565, 331730, 330366, 331837, 331720, 331919, 331955, 332142, 332297, 332101, 331947, 331822, 331700, 333116, 332882, 331160, 331923, 332874, 331694, 331325, 331242, 331069, 330578, 330561, 330433, 330046, 330072, 329940, 329807, 329870, 329714, 329733, 329822, 329890, 330082, 330182, 330292, 330311, 330381, 330190), .Dim = c(155L, 2L), .Dimnames = list( c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "69", "75", "76", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", "123", "160", "163", "70", "71", "91", "92", "93", "94", "95", "96", "97", "98", "99", "100", "101", "102", "103", "104", "105", "106", "108", "109", "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", "120", "121", "122", "124", "125", "126", "127", "128", "129", "130", "131", "132", "133", "134", "135", "136", "161", "162", "137", "138", "140", "141", "142", "143", "144", "145", "146", "147", "148", "149", "150", "151", "152", "153", "154", "155", "156", "157", "158", "159", "164"), c("x", "y")))): setting coordinates cannot be done on Spatial objects, where they have already been set
meuse$log.zn = log(meuse$zinc) class(meuse)
#> [1] "SpatialPointsDataFrame" #> attr(,"package") #> [1] "sp"
dim(meuse)
#> [1] 155 13