如果您来这个问题是为了了解如何制作一组线条(如函数名称所暗示的那样),您可以在“SpatialLines-class”下SpatialLines
的库中找到示例。sp
我发现他们的示例有点奇怪,因此我对其进行了编辑,以便更了解我通常如何查看数据。
## Make some line segments from points
## Note, l1a and l1b are a group of two lines
l1a <- rbind(c(1, 3), c(2,2) ,c(3,2))
l1b <- l1a + .05
l2 <- rbind(c(1,1), c(2,1.5), c(3,1))
## At this point it's just a matrix, and you can plot the points
plot(l1a, type="l", xlim=c(1,3.25), ylim=c(2,3.25), xlab="", ylab="")
lines(l1b)

## Make convert the matrix objects to line objects
Sl1a <- Line(l1a)
Sl1b <- Line(l1b)
Sl2 <- Line(l2)
## Group the individual lines into "lines"
S1 <- Lines(list(Sl1a, Sl1b), ID="a")
S2 <- Lines(list(Sl2), ID="b")
## Now combine the line groups into a "spatial line object"
Sl <- SpatialLines(list(S1,S2))
## Plot the group, then (for illustration) add each line
## separately with color to illustrate the groups
plot(Sl)
plot(SpatialLines(list(S1)), add=T, col="red")
plot(SpatialLines(list(S2)), add=T, col="blue")
## Examine the properties
summary(Sl)
plot(Sl, col = c("red", "blue"))
两个空间线图如下所示:

请注意,矩阵对象在示例中已命名为行。我看不出这样做有什么好处,而且令人困惑,因为名称重叠但与给定的 ID 不对应。