如何利用稀疏采样数据制作地形图?

发布于 2024-08-03 14:05:49 字数 617 浏览 8 评论 0原文

我需要制作地形图,而我只有相当稀疏的(x, y, 高度)数据样本。显然我无法制作一张完全准确的地图,但我想要一张在某种意义上“平滑”的地图。我需要量化“平滑度”(可能是表面曲率平方平均值的倒数),并且我想最小化作为两个量之和的目标函数:

  • 表面的粗糙度
  • 高度之间的均方距离采样点的表面和该点的实际测量高度

因为我真正想要的是地形图,所以我真的在寻找一种构建恒定高度等高线的方法,并且可能有一些巧妙的几何方法来做到这一点无需谈论表面。当然我希望轮廓线也能平滑。

欢迎任何和所有建议。我希望这是一个众所周知的数值问题。我对 C 语言非常熟悉,并且具备 FORTRAN 的应用知识。关于Matlab和R我相当一无所知。


关于我们的样本所在的位置:我们计划大致均匀的间距,但我们会在地形更有趣的地方采集更多样本。例如,我们将对山区进行比平原更密集的采样。但我们在抽样方面肯定有一些选择,如果可以简化问题,甚至可以抽样。唯一的问题是

  • 我们不知道需要绘制多少地形才能找到我们正在寻找的要素。

  • 取样的费用适中,大约需要 10 分钟。因此,对 100x100 网格进行采样可能需要很长时间。

I need to make a topographic map of a terrain for which I have only fairly sparse samples of (x, y, altitude) data. Obviously I can't make a completely accurate map, but I would like one that is in some sense "smooth". I need to quantify "smoothness" (probably the reciprocal the average of the square of the surface curvature) and I want to minimize an objective function that is the sum of two quantities:

  • The roughness of the surface
  • The mean square distance between the altitude of the surface at the sample point and the actual measured altitude at that point

Since what I actually want is a topographic map, I am really looking for a way to construct contour lines of constant altitude, and there may be some clever geometric way to do that without ever having to talk about surfaces. Of course I want contour lines also to be smooth.

Any and all suggestions welcome. I'm hoping this is a well-known numerical problem. I am quite comfortable in C and have a working knowledge of FORTRAN. About Matlab and R I'm fairly clueless.


Regarding where our samples are located: we're planning on roughly even spacing, but we'll take more samples where the topography is more interesting. So for example we'll sample mountainous regions more densely than a plain. But we definitely have some choices about sampling, and could take even samples if that simplifies matters. The only issues are

  • We don't know how much terrain we'll need to map in order to find features that we are looking for.

  • Taking a sample is moderately expensive, on the order of 10 minutes. So sampling a 100x100 grid could take a long time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

写给空气的情书 2024-08-10 14:05:49

克里金插值可能对平滑插值稀疏样本有一定用处。

Kriging interpolation may be of some use for smoothly interpolating your sparse samples.

萌辣 2024-08-10 14:05:49

R 有许多不同的相关工具。特别是空间视图。类似的问题 之前在 R-Help 中被问过,所以你可能想看看

查看 contour 函数。以下是一些数据:

x <- seq(-3,3)
y <- seq(-3,3)

z <- outer(x,y, function(x,y,...) x^2 + y^2 )

初始绘图有些粗糙:

contour(x,y,z, lty=1)

Bill Dunlap 建议改进:“将光滑表面拟合到数据上,在更精细的网格上评估该表面,并将结果传递给轮廓,效果通常会更好。这可以确保轮廓线不会相互交叉,并且往往会避免因平滑轮廓线本身而产生的虚假循环。薄板样条线(来自库(“字段”)的 Tps)和黄土(以及其他)可以适合表面。”

library("fields")
contour(predict.surface(Tps(as.matrix(expand.grid(x=x,y=y)),as.vector(z))))

这会产生非常平滑的绘图,因为它首先使用 Tps() 来拟合数据,然后调用 contour。它最终看起来像这样(如果您希望它有阴影,您也可以使用filled.contour):

对于绘图,您可以使用lattice(如上例所示)或 ggplot2 包。在这种情况下,请使用 geom_contour() 函数。可以在此处找到示例(ht Thierry)

ds <- matrix(rnorm(100), nrow = 10) 
library(reshape) 
molten <- melt(data = ds) 
library(ggplot2) 
ggplot(molten, aes(x = X1, y = X2, z = value)) + geom_contour()

R has many different relevant tools. In particular, have a look at the spatial view. A similar question was asked in R-Help before, so you may want to look at that.

Look at the contour functions. Here's some data:

x <- seq(-3,3)
y <- seq(-3,3)

z <- outer(x,y, function(x,y,...) x^2 + y^2 )

An initial plot is somewhat rough:

contour(x,y,z, lty=1)

Bill Dunlap suggested an improvement: "It often works better to fit a smooth surface to the data, evaluate that surface on a finer grid, and pass the result to contour. This ensures that contour lines don't cross one another and tends to avoid the spurious loops that you might get from smoothing the contour lines themselves. Thin plate splines (Tps from library("fields")) and loess (among others) can fit the surface."

library("fields")
contour(predict.surface(Tps(as.matrix(expand.grid(x=x,y=y)),as.vector(z))))

This results in a very smooth plot, because it uses Tps() to fit the data first, then calls contour. It ends up looking like this (you can also use filled.contour if you want it to be shaded):

For the plot, you can use either lattice (as in the above example) or the ggplot2 package. Use the geom_contour() function in that case. An example can be found here (ht Thierry):

ds <- matrix(rnorm(100), nrow = 10) 
library(reshape) 
molten <- melt(data = ds) 
library(ggplot2) 
ggplot(molten, aes(x = X1, y = X2, z = value)) + geom_contour()
浮生面具三千个 2024-08-10 14:05:49

轮廓算法的精彩回顾,您可能需要先对表面进行网格化才能插值到网格上。

Excellent review of contouring algorithm, you might need to mesh the surface first to interpolate onto a grid.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文