1. <i id='dw6SF'><tr id='dw6SF'><dt id='dw6SF'><q id='dw6SF'><span id='dw6SF'><b id='dw6SF'><form id='dw6SF'><ins id='dw6SF'></ins><ul id='dw6SF'></ul><sub id='dw6SF'></sub></form><legend id='dw6SF'></legend><bdo id='dw6SF'><pre id='dw6SF'><center id='dw6SF'></center></pre></bdo></b><th id='dw6SF'></th></span></q></dt></tr></i><div id='dw6SF'><tfoot id='dw6SF'></tfoot><dl id='dw6SF'><fieldset id='dw6SF'></fieldset></dl></div>

      <legend id='dw6SF'><style id='dw6SF'><dir id='dw6SF'><q id='dw6SF'></q></dir></style></legend>

      <tfoot id='dw6SF'></tfoot>
        <bdo id='dw6SF'></bdo><ul id='dw6SF'></ul>
    1. <small id='dw6SF'></small><noframes id='dw6SF'>

      修复 Shapely 中的无效多边形

      时间:2023-09-12
      • <bdo id='wMmxk'></bdo><ul id='wMmxk'></ul>

        <legend id='wMmxk'><style id='wMmxk'><dir id='wMmxk'><q id='wMmxk'></q></dir></style></legend>

          • <tfoot id='wMmxk'></tfoot>

              <i id='wMmxk'><tr id='wMmxk'><dt id='wMmxk'><q id='wMmxk'><span id='wMmxk'><b id='wMmxk'><form id='wMmxk'><ins id='wMmxk'></ins><ul id='wMmxk'></ul><sub id='wMmxk'></sub></form><legend id='wMmxk'></legend><bdo id='wMmxk'><pre id='wMmxk'><center id='wMmxk'></center></pre></bdo></b><th id='wMmxk'></th></span></q></dt></tr></i><div id='wMmxk'><tfoot id='wMmxk'></tfoot><dl id='wMmxk'><fieldset id='wMmxk'></fieldset></dl></div>
                  <tbody id='wMmxk'></tbody>
              • <small id='wMmxk'></small><noframes id='wMmxk'>

                本文介绍了修复 Shapely 中的无效多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                Shapely 将多边形定义为无效,如果它的任何线段相交,包括共线的线段.许多软件包会创建一个带有切口"的区域或区域,如下所示,它具有共线段:

                Shapely defines a Polygon as invalid if any of its segments intersect, including segments that are colinear. Many software packages will create a region or area with a "cutout" as shown here which has colinear segments:

                >>> pp = Polygon([(0,0), (0,3), (3,3), (3,0), (2,0), 
                                  (2,2), (1,2), (1,1), (2,1), (2,0), (0,0)])
                >>> pp.is_valid
                WARNING:shapely.geos:Self-intersection at or near point 2 0
                False
                

                当然,切口可以在 Shapely 中本地实现,或者同样的几何图形可以实现为两个有效的多边形,但如果我只有上面显示的点列表,是否有一个容易修复"的方法(创建有效的此点列表中的几何图形)?

                Naturally, the cutout can be implemented natively in Shapely, or this same geometry can be implemented as two valid polygons, but if I only have the list of points shown above, is there an easy to "fix" this (create valid geometry from this list of points)?

                推荐答案

                我找到了适用于特定情况的解决方案:

                I found a solution that works for the specific case given:

                >>> pp2 = pp.buffer(0)
                >>> pp2.is_valid
                True
                >>> pp2.exterior.coords[:]
                [(0.0, 0.0), (0.0, 3.0), (3.0, 3.0), (3.0, 0.0), (2.0, 0.0), (0.0, 0.0)]
                >>> pp2.interiors[0].coords[:]
                [(2.0, 1.0), (2.0, 2.0), (1.0, 2.0), (1.0, 1.0), (2.0, 1.0)]
                

                这篇关于修复 Shapely 中的无效多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:python opencv - 斑点检测或圆形检测 下一篇:如果一个失败了,如何跳过课堂上的其余测试?

                相关文章

                最新文章

                  <legend id='CmVM4'><style id='CmVM4'><dir id='CmVM4'><q id='CmVM4'></q></dir></style></legend>
                1. <tfoot id='CmVM4'></tfoot>
                    <bdo id='CmVM4'></bdo><ul id='CmVM4'></ul>

                    <i id='CmVM4'><tr id='CmVM4'><dt id='CmVM4'><q id='CmVM4'><span id='CmVM4'><b id='CmVM4'><form id='CmVM4'><ins id='CmVM4'></ins><ul id='CmVM4'></ul><sub id='CmVM4'></sub></form><legend id='CmVM4'></legend><bdo id='CmVM4'><pre id='CmVM4'><center id='CmVM4'></center></pre></bdo></b><th id='CmVM4'></th></span></q></dt></tr></i><div id='CmVM4'><tfoot id='CmVM4'></tfoot><dl id='CmVM4'><fieldset id='CmVM4'></fieldset></dl></div>

                  1. <small id='CmVM4'></small><noframes id='CmVM4'>