我正在尝试从最初包含在 SpatialPolygons 对象中的众多多边形中提取坐标:
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)))
Srs1 = Polygons(list(Sr1), "s1")
Srs2 = Polygons(list(Sr2), "s2")
SpP = SpatialPolygons(list(Srs1,Srs2), 1:2)
我正在尝试从 SpP 对象中提取 Sr1 和 Sr2 的坐标。我在堆栈交换的其他地方看到了这段代码:
Coords<-SpP@polygons[[2]]@Polygons[[1]]@coords
我无法理解方括号中索引的不匹配,但它运行。但输出与我在 Sr1 或 Sr2 中指定的坐标不匹配。我已经尝试了所有索引组合,但无法得到我正在寻找的答案!