Python、GIS 和 Fortran:尝试从 xy 点数据创建多个多边形

发布于 2024-12-05 18:11:27 字数 551 浏览 4 评论 0原文

我已经研究这个问题有一段时间了,但在 ESRI 论坛页面或我编写的一些 FORTRAN 三角测量脚本上没有找到任何乐趣。

我有两个 .csv 文件,其中包含数百个 xy 点数据。这些点代表潮间带的高端和低端。高点和低点彼此平行,我想创建多边形条子,将其中每英尺的四个点连接成单独的多边形。多边形的高度为 x,具体取决于高点和低点之间的距离。下面的链接显示了两个图像来说明我的意思:

http://forums.arcgis.com/threads/39757-Feature-to-Line..?p=135880&posted=1#post135880

主要问题是将多边形编写为脚本在角落里形成正确的形状。据我所知,在绕弯道移动时,不能有底部直径为 1 英尺、顶部直径为 1 英尺的多边形。但这只是我在尝试解决此问题时遇到的众多问题之一......

任何帮助将不胜感激, 谢谢

I've been working on this problem for awhile and have found no joy on the ESRI forum page or with some FORTRAN triangulation script I wrote.

I have two .csv files with hundreds of xy point data in. These points represent the high and low end of an intertidal range. The high and low points run parallel to each other and I want to create polygon slivers that connect four of those points every foot into separate polygons. The height of the polygon would be x depending upon the distance between the high and low points. The below link shows two images that illustrate what I mean:

http://forums.arcgis.com/threads/39757-Feature-to-Line..?p=135880&posted=1#post135880

The main problem has been scripting the polygons to form correctly in the corners. I understand that you cannot have a polygon that is 1ft in diameter at the bottom and 1ft in diameter at the top when moving round a bend. But this is just one of many problems I've encountered in trying to solve this...

Any help would be greatly appreciated,
Thanks

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

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

发布评论

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

评论(1

迷爱 2024-12-12 18:11:27

这应该适用于插值(假设潮汐线是距岸上某个控制点的 x,y 距离):

import math

example_triangle = [[0,0], [5,5], [0,5], [0,0]]
high_tide_line = [[0, 0], [5., 1.5], [10., 3.2], [20., 1.], [30., 4.5], [80.,2.], [80,0]]
low_tide_line = [[0, 10.], [5., 11.5], [10., 13.2], [20., 11.], [30., 14.5], [80., 12.], [80, 10]]

def points_from_geom(geom):
    idx = 0
    line_lengths = []
    unit_vectors = []
    interpolated_points = []
    while idx < (len(geom) - 1):
        dy, dx = ((geom[idx+1][1] - geom[idx][1]), (geom[idx+1][0] - geom[idx][0]))
        line_lengths.append(math.sqrt(dy**2 + dx**2))
        try:
            angle = math.atan(dy/dx)
            unit_vectors.append([math.cos(angle)*cmp(dx, 0),
                math.sin(angle)*cmp(dy, 0)])
        except ZeroDivisionError:
            if geom[idx+1][1] < geom[idx][1]:
                direction = [0, -1]
            else:
                direction = [0, 1]
            unit_vectors.append(direction)
        idx += 1

    for i, length in enumerate(line_lengths):
        inter = 0
        while inter <= length:
            interpolated_points.append([geom[i][0] + unit_vectors[i][0]*inter,\
                geom[i][1] + unit_vectors[i][1]*inter])
            inter += .3048 # a ft in proper units ;)

    return interpolated_points

ln1 = points_from_geom(example_triangle)
ln2 = points_from_geom(high_tide_line)
ln3 = points_from_geom(low_tide_line)

print ln1, ln2, ln3

有很多不同的方法来制作多边形。我可能尝试的是确定参考海岸线,然后以固定间隔或在每个线段的中间取垂直线,然后与相邻海岸线上的交点制作一个多边形或边界框。顺便说一句,在实际应用程序中,您需要确保 cmp 不在 (0,0) 上运行。

This should work for the interpolation (say the tide line is x, y distance from some control point on shore):

import math

example_triangle = [[0,0], [5,5], [0,5], [0,0]]
high_tide_line = [[0, 0], [5., 1.5], [10., 3.2], [20., 1.], [30., 4.5], [80.,2.], [80,0]]
low_tide_line = [[0, 10.], [5., 11.5], [10., 13.2], [20., 11.], [30., 14.5], [80., 12.], [80, 10]]

def points_from_geom(geom):
    idx = 0
    line_lengths = []
    unit_vectors = []
    interpolated_points = []
    while idx < (len(geom) - 1):
        dy, dx = ((geom[idx+1][1] - geom[idx][1]), (geom[idx+1][0] - geom[idx][0]))
        line_lengths.append(math.sqrt(dy**2 + dx**2))
        try:
            angle = math.atan(dy/dx)
            unit_vectors.append([math.cos(angle)*cmp(dx, 0),
                math.sin(angle)*cmp(dy, 0)])
        except ZeroDivisionError:
            if geom[idx+1][1] < geom[idx][1]:
                direction = [0, -1]
            else:
                direction = [0, 1]
            unit_vectors.append(direction)
        idx += 1

    for i, length in enumerate(line_lengths):
        inter = 0
        while inter <= length:
            interpolated_points.append([geom[i][0] + unit_vectors[i][0]*inter,\
                geom[i][1] + unit_vectors[i][1]*inter])
            inter += .3048 # a ft in proper units ;)

    return interpolated_points

ln1 = points_from_geom(example_triangle)
ln2 = points_from_geom(high_tide_line)
ln3 = points_from_geom(low_tide_line)

print ln1, ln2, ln3

There are a lot of different ways to do the polygons. What I might try is determine a reference shoreline, then take perpendicular lines to it at fixed intervals, or in the middle of each line segment, then make a polygon or bounding box with the intersection on the adjacent shoreline. BTW in a real application you would need to make sure cmp is not operating on (0,0).

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