相关疑难解决方法(0)

从SpatialPolygons和其他sp类中提取要素坐标

Package sp为不同的空间概念(点,线,多边形)提供了许多类.对于某些类,访问要素坐标很简单,例如SpatialLines.所有示例均来自各个类帮助页面.

l1 = cbind(c(1,2,3),c(3,2,2))
l1a = cbind(l1[,1]+.05,l1[,2]+.05)
l2 = cbind(c(1,2,3),c(1,1.5,1))
Sl1 = Line(l1)
Sl1a = Line(l1a)
Sl2 = Line(l2)
S1 = Lines(list(Sl1, Sl1a), ID="a")
S2 = Lines(list(Sl2), ID="b")
Sl = SpatialLines(list(S1,S2))
coordinates(Sl)
# [prints a list of two with corresponding segments]
Run Code Online (Sandbox Code Playgroud)

对于SpatialPolygons,coordinates()返回多边形中心,如下所示.

Sr1 = Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2)))
Sr2 = Polygon(cbind(c(5,4,2,5),c(2,3,2,2)))
Sr3 = Polygon(cbind(c(4,4,5,10,4),c(5,3,2,5,5)))
Sr4 = Polygon(cbind(c(5,6,6,5,5),c(4,4,3,3,4)), hole = TRUE)

Srs1 = Polygons(list(Sr1), "s1")
Srs2 = Polygons(list(Sr2), "s2")
Srs3 = Polygons(list(Sr3, Sr4), "s3/4")
SpP = …
Run Code Online (Sandbox Code Playgroud)

r class spatial ggplot2

14
推荐指数
1
解决办法
7334
查看次数

标签 统计

class ×1

ggplot2 ×1

r ×1

spatial ×1