小编mic*_*elk的帖子

插值R中的路径/曲线

在R中,我想插入一个内插点之间距离恒定的任意路径.

测试数据看起来像这样:

require("rgdal", quietly = TRUE)
require("ggplot2", quietly = TRUE)
r <- readOGR(".", "line", verbose = FALSE)
coords <- as.data.frame(r@lines[[1]]@Lines[[1]]@coords)
names(coords) <- c("x", "y")
print(coords)

x         y
-0.44409  0.551159
-1.06217  0.563326
-1.09867  0.310255
-1.09623 -0.273754
-0.67283 -0.392990
-0.03772 -0.273754
 0.63633 -0.015817
 0.86506  0.473291
 1.31037  0.998899
 1.43934  0.933198
 1.46854  0.461124
 1.39311  0.006083
 1.40284 -0.278621
 1.54397 -0.271321

p.orig <- ggplot(coords, aes(x = x, y = y)) + geom_path(colour = "red") + 
    geom_point(colour = "yellow")
print(p.orig)
Run Code Online (Sandbox Code Playgroud)

http://i.imgur.com/0tusA.png

我尝试了不同的方法,但没有一个真正令人满意:

  • aspline (阿克玛包)
  • approx
  • bezierCurve
  • 随着tourr …

curve interpolation r

11
推荐指数
2
解决办法
4804
查看次数

标签 统计

curve ×1

interpolation ×1

r ×1