<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python 2.7 Determine inner ring in JSON in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-2-7-determine-inner-ring-in-json/m-p/1140938#M63667</link>
    <description>&lt;P&gt;You know, I'm not really sure. I've worked with querying a REST URL and using the returned JSON, only to have the resulting polygons be flagged as "invalid", and I ended up getting really strange area calculations.&lt;/P&gt;&lt;P&gt;As far as "how do you tell", you can check out &lt;A href="https://stackoverflow.com/a/1165943" target="_blank"&gt;this great Stack Overflow answer&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Is there a reason you have to work with the polygons this way, by the way?&lt;/P&gt;</description>
    <pubDate>Fri, 04 Feb 2022 21:18:56 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2022-02-04T21:18:56Z</dc:date>
    <item>
      <title>Python 2.7 Determine inner ring in JSON</title>
      <link>https://community.esri.com/t5/python-questions/python-2-7-determine-inner-ring-in-json/m-p/1140897#M63663</link>
      <description>&lt;P&gt;Trying to calculate acreage/area from polygon array loaded from JSON result of map service query and running into issue with geometries that contain "holes".&amp;nbsp; From what I know, the first list of coordinate pairs (index 0) is the "outer" polygon, then all other coordinate pairs would be the interior rings.&amp;nbsp; This is easiest enough to setup a condition to identify and calculate total area.&amp;nbsp; For example area of a polygon with two interior rings could be determined by:&lt;/P&gt;&lt;P&gt;ring[0] area - ring[1] area - ring[2] area = total area&lt;/P&gt;&lt;P&gt;Got it.&amp;nbsp; However, what if the polygon consists of 1 ring with interior rings and a ring coincident.&amp;nbsp; That is, there are what looks like 2 polygons coincident to each other but one of them contains holes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I come up with the total area in this case?&amp;nbsp; Example below shows 2 coincident polygons, 1 with holes that needs to have the area of interior rings subtracted from the overall ring, while the coincident polygon only has 1 ring that must be added to the total area.&lt;/P&gt;&lt;P&gt;Edit: to simplify my question, how do I arrive at the count of 2 rings (area of 1 "island" ring, area 1 outer ring - total area of 7 interior rings)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JamesCrandall_0-1644001112373.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33175iDCAC52C961827C8D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JamesCrandall_0-1644001112373.png" alt="JamesCrandall_0-1644001112373.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Here's the json for the rings in picture:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
        "rings" : [
          [
            [
              -8960520,
              3141929
            ],
            [
              -8960482,
              3141916
            ],
            [
              -8960381,
              3141979
            ],
            [
              -8960297,
              3142183
            ],
            [
              -8960220,
              3142291
            ],
            [
              -8960267,
              3142363
            ],
            [
              -8959212,
              3142329
            ],
            [
              -8959216,
              3140075
            ],
            [
              -8960546,
              3141806
            ],
            [
              -8960599,
              3141897
            ],
            [
              -8960692,
              3142376
            ],
            [
              -8960637,
              3142374
            ],
            [
              -8960622,
              3142346
            ],
            [
              -8960608,
              3142230
            ],
            [
              -8960516,
              3142015
            ],
            [
              -8960520,
              3141929
            ]
          ],
          [
            [
              -8960049,
              3141823
            ],
            [
              -8960001,
              3141812
            ],
            [
              -8959983,
              3141860
            ],
            [
              -8960017,
              3141990
            ],
            [
              -8960058,
              3142011
            ],
            [
              -8960083,
              3141987
            ],
            [
              -8960049,
              3141823
            ]
          ],
          [
            [
              -8959472,
              3141918
            ],
            [
              -8959391,
              3141908
            ],
            [
              -8959340,
              3141951
            ],
            [
              -8959320,
              3142025
            ],
            [
              -8959325,
              3142112
            ],
            [
              -8959387,
              3142168
            ],
            [
              -8959484,
              3142163
            ],
            [
              -8959513,
              3142124
            ],
            [
              -8959472,
              3141918
            ]
          ],
          [
            [
              -8959828,
              3142151
            ],
            [
              -8959808,
              3142211
            ],
            [
              -8959826,
              3142302
            ],
            [
              -8959875,
              3142344
            ],
            [
              -8959943,
              3142320
            ],
            [
              -8959986,
              3142228
            ],
            [
              -8959959,
              3142148
            ],
            [
              -8959927,
              3142120
            ],
            [
              -8959858,
              3142113
            ],
            [
              -8959828,
              3142151
            ]
          ],
          [
            [
              -8959663,
              3141625
            ],
            [
              -8959585,
              3141438
            ],
            [
              -8959535,
              3141389
            ],
            [
              -8959428,
              3141379
            ],
            [
              -8959399,
              3141424
            ],
            [
              -8959384,
              3141551
            ],
            [
              -8959497,
              3141761
            ],
            [
              -8959571,
              3141760
            ],
            [
              -8959663,
              3141625
            ]
          ],
          [
            [
              -8959960,
              3141599
            ],
            [
              -8960028,
              3141615
            ],
            [
              -8960074,
              3141591
            ],
            [
              -8960098,
              3141499
            ],
            [
              -8960095,
              3141436
            ],
            [
              -8960049,
              3141324
            ],
            [
              -8960008,
              3141263
            ],
            [
              -8959800,
              3141169
            ],
            [
              -8959793,
              3141018
            ],
            [
              -8959741,
              3140928
            ],
            [
              -8959722,
              3140834
            ],
            [
              -8959630,
              3140750
            ],
            [
              -8959570,
              3140741
            ],
            [
              -8959528,
              3140782
            ],
            [
              -8959542,
              3140877
            ],
            [
              -8959601,
              3141041
            ],
            [
              -8959719,
              3141213
            ],
            [
              -8959733,
              3141325
            ],
            [
              -8959797,
              3141385
            ],
            [
              -8959960,
              3141599
            ]
          ],
          [
            [
              -8959346,
              3140751
            ],
            [
              -8959388,
              3140703
            ],
            [
              -8959379,
              3140596
            ],
            [
              -8959479,
              3140586
            ],
            [
              -8959518,
              3140560
            ],
            [
              -8959514,
              3140503
            ],
            [
              -8959403,
              3140475
            ],
            [
              -8959393,
              3140355
            ],
            [
              -8959278,
              3140327
            ],
            [
              -8959249,
              3140351
            ],
            [
              -8959237,
              3140406
            ],
            [
              -8959333,
              3140479
            ],
            [
              -8959343,
              3140579
            ],
            [
              -8959291,
              3140665
            ],
            [
              -8959296,
              3140732
            ],
            [
              -8959346,
              3140751
            ]
          ],
          [
            [
              -8960421.4573999997,
              3141207.5951999985
            ],
            [
              -8960651.4805999994,
              3140355.0742999986
            ],
            [
              -8960730.3613000009,
              3140457.7377999984
            ],
            [
              -8960501.8148999996,
              3141210.1849000007
            ],
            [
              -8960421.4573999997,
              3141207.5951999985
            ]
          ]
        ]
      }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 19:09:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-2-7-determine-inner-ring-in-json/m-p/1140897#M63663</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2022-02-04T19:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: Python 2.7 Determine inner ring in JSON</title>
      <link>https://community.esri.com/t5/python-questions/python-2-7-determine-inner-ring-in-json/m-p/1140915#M63664</link>
      <description>&lt;P&gt;Polygons &lt;EM&gt;ought &lt;/EM&gt;to follow the &lt;A href="https://www.rfc-editor.org/rfc/rfc7946#section-3.1.6" target="_self"&gt;right-hand rule&lt;/A&gt;, i.e., outer rings go counter-clockwise, inner rings (holes) go clockwise. So if you first check the direction of the polygon vertices, you can then calculate (sum of right-hand areas) - (sum of left-hand areas).&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 19:45:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-2-7-determine-inner-ring-in-json/m-p/1140915#M63664</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-02-04T19:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Python 2.7 Determine inner ring in JSON</title>
      <link>https://community.esri.com/t5/python-questions/python-2-7-determine-inner-ring-in-json/m-p/1140923#M63666</link>
      <description>&lt;P&gt;Is direction guaranteed and how is direction determined?&amp;nbsp; Does it matter how the polygon was digitized (ie. an island polygon that was digitized clockwise)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks Josh!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 20:56:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-2-7-determine-inner-ring-in-json/m-p/1140923#M63666</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2022-02-04T20:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Python 2.7 Determine inner ring in JSON</title>
      <link>https://community.esri.com/t5/python-questions/python-2-7-determine-inner-ring-in-json/m-p/1140938#M63667</link>
      <description>&lt;P&gt;You know, I'm not really sure. I've worked with querying a REST URL and using the returned JSON, only to have the resulting polygons be flagged as "invalid", and I ended up getting really strange area calculations.&lt;/P&gt;&lt;P&gt;As far as "how do you tell", you can check out &lt;A href="https://stackoverflow.com/a/1165943" target="_blank"&gt;this great Stack Overflow answer&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Is there a reason you have to work with the polygons this way, by the way?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 21:18:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-2-7-determine-inner-ring-in-json/m-p/1140938#M63667</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-02-04T21:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: Python 2.7 Determine inner ring in JSON</title>
      <link>https://community.esri.com/t5/python-questions/python-2-7-determine-inner-ring-in-json/m-p/1140946#M63668</link>
      <description>&lt;P&gt;These are geometries created by web tools, unvalidated / uncontrolled (the users can create any kind of whacked-out polygon imaginable) so I think I may have to just pursue getting out of reading ring coordinate all together and just convert the JSON to a feature class.&amp;nbsp; Then reading geometries via da.cursor is probably going to be much easier/cleaner way.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 21:35:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-2-7-determine-inner-ring-in-json/m-p/1140946#M63668</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2022-02-04T21:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: Python 2.7 Determine inner ring in JSON</title>
      <link>https://community.esri.com/t5/python-questions/python-2-7-determine-inner-ring-in-json/m-p/1140978#M63670</link>
      <description>&lt;P&gt;clockwise outer rings and cc-wise inner rings give rise to negative areas using the "shoelace" formula (most gis packages implement this in some form or another).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reverse that and the areas are positive.&amp;nbsp; If somehow inner and outer are both going in the same direction or aren't enclosed in the outer ring, then all bets are off.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Feb 2022 00:39:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-2-7-determine-inner-ring-in-json/m-p/1140978#M63670</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-02-05T00:39:11Z</dc:date>
    </item>
  </channel>
</rss>

