Examples for 'sp::SpatialMultiPointsDataFrame-class'


Class "SpatialMultiPointsDataFrame"

Aliases: SpatialMultiPointsDataFrame-class [,SpatialMultiPointsDataFrame-method coerce,SpatialMultiPointsDataFrame,data.frame-method coerce,SpatialMultiPointsDataFrame,SpatialPointsDataFrame-method show,SpatialMultiPointsDataFrame-method points,SpatialMultiPointsDataFrame-method coordinates,SpatialMultiPointsDataFrame-method as.data.frame.SpatialMultiPointsDataFrame dim.SpatialMultiPointsDataFrame print.SpatialMultiPointsDataFrame rbind.SpatialMultiPointsDataFrame row.names.SpatialMultiPointsDataFrame

Keywords: classes

### ** Examples

# create three sets of points:
cl1 = cbind(rnorm(3, 10), rnorm(3, 10))
cl2 = cbind(rnorm(5, 10), rnorm(5,  0))
cl3 = cbind(rnorm(7,  0), rnorm(7, 10))

mpdf = SpatialMultiPointsDataFrame(list(cl1, cl2, cl3), data.frame(a = 1:3))
mpdf
               coordinates a
1     (8.664846, 11.06043) 1
1.1    (10.74859, 10.0176) 1
1.2   (10.65919, 9.895568) 1
2   (9.469883, -0.0663676) 2
2.1 (9.169174, -0.0810618) 2
2.2 (9.463523, 0.02950892) 2
2.3 (10.03683, -0.7822603) 2
2.4  (8.626715, 0.2412942) 2
3    (0.2164133, 9.891674) 3
3.1  (0.3235896, 10.22716) 3
3.2   (-1.20895, 9.976981) 3
3.3 (-0.1986798, 8.782487) 3
3.4  (0.2500321, 9.897905) 3
3.5  (-0.9788763, 10.8549) 3
3.6  (0.7646462, 11.07077) 3
plot(mpdf, col = mpdf$a, cex = 1:3)
plot of chunk example-sp-SpatialMultiPointsDataFrame-class-1
as(mpdf, "data.frame")
             X1          X2 index a
X1    8.6648462 11.06043259     1 1
X1.1 10.7485911 10.01759870     1 1
X1.2 10.6591855  9.89556761     1 1
X2    9.4698825 -0.06636760     2 2
X2.1  9.1691745 -0.08106180     2 2
X2.2  9.4635234  0.02950892     2 2
X2.3 10.0368307 -0.78226033     2 2
X2.4  8.6267153  0.24129417     2 2
X3    0.2164133  9.89167417     3 3
X3.1  0.3235896 10.22715575     3 3
X3.2 -1.2089500  9.97698111     3 3
X3.3 -0.1986798  8.78248678     3 3
X3.4  0.2500321  9.89790498     3 3
X3.5 -0.9788763 10.85489645     3 3
X3.6  0.7646462 11.07076680     3 3
mpdf[1:2,]
               coordinates a
1     (8.664846, 11.06043) 1
1.1    (10.74859, 10.0176) 1
1.2   (10.65919, 9.895568) 1
2   (9.469883, -0.0663676) 2
2.1 (9.169174, -0.0810618) 2
2.2 (9.463523, 0.02950892) 2
2.3 (10.03683, -0.7822603) 2
2.4  (8.626715, 0.2412942) 2

[Package sp version 1.5-0 Index]