Postgis多边形内的随机点
如果我在 Postgis 中有一个多边形,我如何找到/计算多边形内的随机点?
If i have a polygon in Postgis how can i find/calculate random points inside the polygon?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
@Mike 引用的链接没有代码,但 Dr.JTS 提供了很好的线索:
“点密度”地图...“本质上,这涉及创建一组位于给定多边形内的 N 个随机放置的点”。函数执行此操作:输入是多边形,输出是随机点。
这些链接具有相同的 SQL/PostGIS 函数
RandomPoint(Geometry)
:sorokine 2011 和 osgeo.org/postgis/维基百科。第二个链接 (wiki) 更完整,解释并显示了示例,以及作为问题答案的函数RandomPointsInPolygon(geometry,integer)
。扩展 solion 以输入“每个区域的点密度”,或点之间的平均距离:
The link cited by @Mike not have a code, but good clues from Dr.JTS:
"dot-density" maps... "Essentially this involves creating a set of N randomly-placed points which lie within a given polygon". A function do this: the input is the polygon, the output the random points.
These links have the same SQL/PostGIS function
RandomPoint(Geometry)
: sorokine 2011 and osgeo.org/postgis/wiki. The second link (wiki) is more complete, explaning and showing examples, and a functionRandomPointsInPolygon(geometry,integer)
that is an answer to the problem.Extending the solion to input "density of points per area", or average distance between points:
Postgis 2.3.0 及更高版本有一个新函数,可以将点生成到多边形ST_GeneratePoints。
The Postgis version 2.3.0 and upper have a new function to generate points into polygon ST_GeneratePoints.