从规则间隔的数据生成轮廓线

发布于 2024-07-14 21:42:06 字数 263 浏览 12 评论 0原文

我目前正在从事一个数据可视化项目。我的目标是从网格数据中生成等高线,即等值线。数据可以是温度、天气数据或任何其他环境参数,但唯一的条件是它必须是有规律地间隔。 我在互联网上搜索,但是我找不到一个好的算法、伪代码或源代码来从网格生成轮廓线。 有人知道从网格数据生成等高线的库、源代码或算法吗? 如果您的建议具有良好的运行时性能,那就太好了,我不想让我的用户等得太久:)

编辑:感谢您的回复,但等值线有一些限制,比如它们不应该相交 所以仅仅生成贝塞尔曲线并不能实现我的目标。

I am currently working on a data visualization project.My aim is to produce contour lines ,in other words iso-lines, from gridded data.Data can be temperature, weather data or any kind of other environmental parameters but only condition is it must be regularly spaced.
I searched in internet , however i could not find a good algorithm, pseudo-code or source code for producing contour lines from grids.
Does anybody knows a library, source code or an algorithm for producing contour lines from gridded data?
it will be good if your suggestion has a good run time performance, i don't want to wait my users so much :)

Edit: thanks for response but isolines have some constrains like they should not intersects
so just generating bezier curves does not accomplish my goal.

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

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

发布评论

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

评论(4

轻许诺言 2024-07-21 21:42:06

请参阅此问题:如何从高程栅格?

它几乎是重复的,但使用了完全不同的术语。 您会发现制图学和计算机图形学解决了许多相同的问题,但使用不同的术语。

See this question: How to approximate a vector contour from an elevation raster?

It's a near duplicate, but uses quite different terminology. You'll find that cartography and computer graphics solve many of the same problems, but use different terminology for them.

开始看清了 2024-07-21 21:42:06

GNUplot 中提供了一些相当不错的轮廓 - 如果您能够使用可能有帮助的 GPL 代码。

there's some reasonably good contouring available in GNUplot - if you're able to use GPL code that may help.

爱本泡沫多脆弱 2024-07-21 21:42:06

如果您的数据定期放置,那么这可以相当容易地完成(假设我正确理解您的问题)。 首先,您需要确定轮廓的间隔时间。 接下来创建将用于存储等高线信息的网格(我假设只是在此等高线级别数据类型上进行简单的开/关或高程),该网格应该比源数据小一个间隔。

现在这里的技巧是将 2 个网格偏移 1/2 个间隔(实际上不会显示在这样的代码中,但它是我在这里处理的概念)并比较当前点周围的 4 个坐标您正在计算的等高线数据网格。 如果 4 个点中的任何一个位于不同的间隔范围内,则等高线网格中的“像素”应设置为 true(或被交叉的等高线范围的值)。

使用这种方法会出现一个问题,当间隔太细时,会导致多个轮廓相互重叠。

If your data is placed at regular intervals, this can be done fairly easily (assuming I understand your problem correctly). First you need to determine at what interval you want your contours. Next create the grid you are going to use to store the contour information (i'm assuming just a simple on/off or elevation at this contour level type of data), which should be one interval smaller than the source data.

Now the trick here is to offset the 2 grids by 1/2 an interval (won't actually show up in code like this, but its the concept I'm dealing with here) and compare the 4 coordinates surrounding the current point in the contour data grid you are calculating. If any of the 4 points are in a different interval range, then that 'pixel' in the contour grid should be set to true (or the value of the contour range being crossed).

With this method, there will be a problem when the interval is too fine which will cause several contours to overlap onto each other.

小嗷兮 2024-07-21 21:42:06

正如 Paul Tomblin 的链接所暗示的那样,贝塞尔曲线(B 样条曲线的子集)是解决您的问题的成熟解决方案。 如果运行时性能是一个问题,贝塞尔曲线还有一个额外的好处,那就是可以通过非常快的 de Casteljau 算法来构造,而不是根据参数方程来绘制它们。 如果您使用 DirectX,它有一个用于 de Casteljau 的库函数,但使用描述它的 1001 个网页自行编写一个库函数应该不成问题。

As the link from Paul Tomblin suggests, Bezier curves (which are a subset of B-splines) are a ripe solution for your problem. If runtime performance is an issue, Bezier curves have the added benefit of being constructable via the very fast de Casteljau algorithm, instead of drawing them according to the parametric equations. On the off chance you're working with DirectX, it has a library function for the de Casteljau, but it should not be challenging to brew one yourself using the 1001 web pages that describe it.

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