<?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 Create current status for a layer of overlap polygons in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/create-current-status-for-a-layer-of-overlap/m-p/1258799#M65598</link>
    <description>&lt;P&gt;I have a polygon layer with many overlap polygons, each one have a time stamp.&lt;/P&gt;&lt;P&gt;I would like to create a "current status" polygon layer that will not have overlap and each polygon will be the latest.&lt;/P&gt;&lt;P&gt;Some polygons that have partially overlap will be changed.&lt;/P&gt;&lt;P&gt;For example I have one polygon from 2020 that have cross polygon from 2019 and anther cross polygon from 2021&lt;/P&gt;&lt;P&gt;The 2020 polygon will be cut by 2021 polygon but not by 2019 polygon.&lt;/P&gt;&lt;P&gt;The only way I could think about is to take the polygons from the original layer one by one the oldest to the newest, with each one to to an Erase and Append on the result layer.&lt;/P&gt;&lt;P&gt;Is there any better way?&lt;/P&gt;</description>
    <pubDate>Thu, 16 Feb 2023 08:02:01 GMT</pubDate>
    <dc:creator>mody_buchbinder</dc:creator>
    <dc:date>2023-02-16T08:02:01Z</dc:date>
    <item>
      <title>Create current status for a layer of overlap polygons</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/create-current-status-for-a-layer-of-overlap/m-p/1258799#M65598</link>
      <description>&lt;P&gt;I have a polygon layer with many overlap polygons, each one have a time stamp.&lt;/P&gt;&lt;P&gt;I would like to create a "current status" polygon layer that will not have overlap and each polygon will be the latest.&lt;/P&gt;&lt;P&gt;Some polygons that have partially overlap will be changed.&lt;/P&gt;&lt;P&gt;For example I have one polygon from 2020 that have cross polygon from 2019 and anther cross polygon from 2021&lt;/P&gt;&lt;P&gt;The 2020 polygon will be cut by 2021 polygon but not by 2019 polygon.&lt;/P&gt;&lt;P&gt;The only way I could think about is to take the polygons from the original layer one by one the oldest to the newest, with each one to to an Erase and Append on the result layer.&lt;/P&gt;&lt;P&gt;Is there any better way?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 08:02:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/create-current-status-for-a-layer-of-overlap/m-p/1258799#M65598</guid>
      <dc:creator>mody_buchbinder</dc:creator>
      <dc:date>2023-02-16T08:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create current status for a layer of overlap polygons</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/create-current-status-for-a-layer-of-overlap/m-p/1258806#M65601</link>
      <description>&lt;P&gt;You can probably whip up some Python script.&lt;/P&gt;&lt;P&gt;But this part is very unclear:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Some polygons that have partially overlap will be changed.&lt;/P&gt;&lt;P&gt;For example I have one polygon from 2020 that have cross polygon from 2019 and anther cross polygon from 2021&lt;/P&gt;&lt;P&gt;The 2020 polygon will be cut by 2021 polygon but not by 2019 polygon.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you clarify that, maybe with a sketch?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 08:41:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/create-current-status-for-a-layer-of-overlap/m-p/1258806#M65601</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-02-16T08:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Create current status for a layer of overlap polygons</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/create-current-status-for-a-layer-of-overlap/m-p/1258902#M65615</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At the top the layer I have, at the bottom the layer I would like to create&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 15:27:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/create-current-status-for-a-layer-of-overlap/m-p/1258902#M65615</guid>
      <dc:creator>mody_buchbinder</dc:creator>
      <dc:date>2023-02-16T15:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Create current status for a layer of overlap polygons</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/create-current-status-for-a-layer-of-overlap/m-p/1258967#M65621</link>
      <description>&lt;P&gt;That sketch helped alot.&lt;/P&gt;&lt;P&gt;It turns out to be relatively easy:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# parameters
polygon_fc = "TestPolygons"
id_field = "IntegerField"
date_field = "DateField"
out_path = "memory/CurrentState"


# copy the feature class
out_fc = arcpy.management.CopyFeatures(polygon_fc, out_path)

# read the input fc
fields = [id_field, date_field, "SHAPE@"]
polygons = [dict(zip(fields, row))
            for row in arcpy.da.SearchCursor(polygon_fc, fields)
            ]

# get unique ids
unique_ids = {p[id_field]
              for p in polygons
              }

# iterate over the unique ids
for uid in unique_ids:
    # get all states of that polygon, sort by date
    states = [p
              for p in polygons
              if p[id_field] == uid
              ]
    states.sort(key=lambda s: s[date_field])
    # start updating the output fc for this id
    with arcpy.da.UpdateCursor(out_fc, ["SHAPE@"], where_clause=f"{id_field} = {uid}", sql_clause=[None, f"ORDER BY {date_field}"]) as cursor:
        # cursor and states are in the same order (oldest to newest)
        for i, row in enumerate(cursor):
            # get the geometry of this row
            state_geometry = states[i]["SHAPE@"]  # == row[0]
            # erase/subtract each newer state
            for k in range(i+1, len(states)):
                newer_state_geometry = states[k]["SHAPE@"]
                state_geometry -= newer_state_geometry  # we can use "-" to get the difference between two polygons
            # update the geometry
            cursor.updateRow([state_geometry])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Original:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1676567318235.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/63018i343764714A0923F2/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_0-1676567318235.png" alt="JohannesLindner_0-1676567318235.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Current state:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1676567341112.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/63019iD29F66B4D84E77C5/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_1-1676567341112.png" alt="JohannesLindner_1-1676567341112.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2023 17:12:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/create-current-status-for-a-layer-of-overlap/m-p/1258967#M65621</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-02-16T17:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create current status for a layer of overlap polygons</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/create-current-status-for-a-layer-of-overlap/m-p/1260780#M65847</link>
      <description>&lt;P&gt;It is a nice code. I did not know I can use minus on geometry.&lt;/P&gt;&lt;P&gt;It is after all doing the erase and append that I suggested&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 05:49:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/create-current-status-for-a-layer-of-overlap/m-p/1260780#M65847</guid>
      <dc:creator>mody_buchbinder</dc:creator>
      <dc:date>2023-02-23T05:49:59Z</dc:date>
    </item>
  </channel>
</rss>

