从 R 中的一组点在地图上绘制平滑区域
如何在 R 中的地图上绘制一组点周围的区域?例如
map('world')
map.axes()
p <- matrix(c(50, 50, 80, 100, 70, 40, 25, 60), ncol=2) # make some points
points(p, pch=19, col="red")
polygon(p, col="blue")
......这给了我一个在每个点都有一个顶点的多边形,但它看起来相当蹩脚。有什么方法可以将多边形“平滑”成某种曲线吗?
how do I plot an area around a set of points on a map in R? e.g.
map('world')
map.axes()
p <- matrix(c(50, 50, 80, 100, 70, 40, 25, 60), ncol=2) # make some points
points(p, pch=19, col="red")
polygon(p, col="blue")
... which gives me a polygon with a vertex at each of the points, but it looks rather crappy. Is there any way to "smooth" the polygon into some sort of curve?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种选择是使用
Hmisc
包中的bezier
函数创建以贝塞尔曲线为边界的多边形。但是我无法让起点/终点整齐地连接起来。例如:One option is to make a polygon bounded by a Bézier curve, using the
bezier
function in theHmisc
package. However I cannot get the start/end point to join up neatly. For example:这是一种方法,绘制多边形并使其像您喜欢的那样漂亮。这实际上与地图上的区域无关,更多地与如何生成多边形的顶点有关。
否则,您可以插入中间顶点并以某种方式平滑它们,并且在经度/纬度地图的背景下,可能使用重投影来获得更真实的线段 - 但这取决于您的目的。
Here's one way, draw the polygon and make it as pretty as you like. This really has nothing to do with areas on maps, more about how you generate the vertices of your polygon.
Otherwise you could interpolate intermediate vertices and smooth them somehow, and in the context of a lon/lat map maybe with use reprojection to get more realistic line segments - but depends on your purpose.