postgis使用点分割多边形

发布于 2024-12-22 19:33:12 字数 144 浏览 3 评论 0原文

我想使用点来提取多边形部分来切割它。 我见过 ST_Dump 和 ST_Split 但它们似乎没有达到目的。我应该创建更多点来创建线段并使用 st_split 来切割它们吗?我认为这太多了,但如果有必要的话我会这样做:)

任何建议都会很好:) 干杯, 一个

I would like to extract polygon parts using points to cut it.
I have seen ST_Dump and ST_Split but they do not seem to do the trick. Should I create more points in order to create a line segment and use st_split to cut them? I think thats too much but I would do it if necessary :)

Any suggestions would be nice :)
Cheers,
A

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

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

发布评论

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

评论(1

不必了 2024-12-29 19:33:13

那么,您想要从多边形的每个边都有一条线串吗?如果这是真的,我想我有一个答案。

首先:我将创建一个视图,其中所有多边形都作为线串。正如您所指出的,您可以使用 ST_Boundary。 (这样第二个查询就很容易编写和读取)

CREATE VEIW my_linestrings as 
    SELECT id,..., ST_BOUNDARY(the_geom) 
    FROM <yourtable>

第二:由于它是一个线串,因此您可以使用 ST_POINTN 来获取第 n 个点,并使用 ST_MAKELINE 来制作一条两段线。

SELECT id,..., ST_MakeLine(ST_PointN(the_geom,x),ST_PointN(the_geom,x+1))
FROM my_linestrings

ST_MakeLine 将为您提供线串段。您可以在 python 中创建一个循环来迭代所有点。如果这是您需要经常做的事情,那么最好使用这些段创建一个新表。

另外,请访问 gis.stackexchange.com 加入我们;)这个问题与您的问题类似,并使用 SQL 来创建一系列循环遍历所有几何图形(而不是Python)。

So, you want a linestring from each edge a polygon? I think I have an answer if that is true.

First: I would create a view that has all you polygons as linestrings. As you've pointed out, you can use ST_Boundary. (So that the second query is easy to write and read)

CREATE VEIW my_linestrings as 
    SELECT id,..., ST_BOUNDARY(the_geom) 
    FROM <yourtable>

Second: Since its a linestring you can use ST_POINTN to get the nth point and ST_MAKELINE to make a two segment line.

SELECT id,..., ST_MakeLine(ST_PointN(the_geom,x),ST_PointN(the_geom,x+1))
FROM my_linestrings

The ST_MakeLine will get you your linestring segment. You can make a loop in python to iterate though all the points. If this is something you need to do a lot, it would probably be best to create a new table with these segments.

Also, come join us at gis.stackexchange.com ;) This question is similiar to yours and uses SQL to create a series to loop through all the geometries (instead of python).

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