小编nya*_*nya的帖子

如何将一组点坐标从凹壳转换为 R 中的多边形?

我有一个alphahull::ashape()结果,我需要将其转换spatstat::owin()为后续空间分析。是否有一个优雅的解决方案如何从凹壳中订购点并将形状转换为owin对象或任何Spatial*对象?对于假设矩阵中coords的有序点,多边形定义为:

geo.owin=try(owin(poly=list(x=coords[,1],y=coords[,2])),silent=T)
if(class(geo.owin)=="try-error") geo.owin=owin(poly=list(x=rev(coords[,1]),y=rev(coords[,2])))
Run Code Online (Sandbox Code Playgroud)

这不可能。该ashape()$edges矩阵包含可以绘制为看起来像多边形的点的坐标,此处提供了该矩阵。但是,这些点没有按照不同的绘图颜色和箭头方向进行排序。

# data
okraj = matrix(c(23.8808, 18.0106, 23.8808, 1.8265, 1.8266, 1.8265, 18.0106, 39.5352, 39.5352, 39.5352, 13.5519, 27.9675, 3.8102, 4.8269, 8.8236, 52.7248, 45.3385, 52.7248, 50.9600, 50.9600, 50.9600, 45.3385, 39.9042, 39.9042, 39.9042, 49.1204, 41.8421, 47.1450, 44.9423, 46.0246, 13.5519, 27.9675, 32.1116, 1.8266, 4.5644, 3.8102, 17.5557, 39.5840, 32.1116, 29.2158, 4.5644, 29.2158, 4.8269, 8.8236, 17.5557, 49.1204, 41.8421, 41.3710, 50.9600, 49.8638, 47.1450, 45.5063, 39.8987, 41.3710, 40.0750, 49.8638), ncol=4, dimnames=list(NULL,c("x1","y1","x2","y2")))

# …
Run Code Online (Sandbox Code Playgroud)

maps r polygon coordinates

5
推荐指数
0
解决办法
559
查看次数

标签 统计

coordinates ×1

maps ×1

polygon ×1

r ×1