<?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 ArcPro how to COPY multipart GEOMETRY between separate layers? in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcpro-how-to-copy-multipart-geometry-between/m-p/1117014#M47855</link>
    <description>&lt;P&gt;How can I copy and replace the multipart polygon GEOMETRY from one feature (e.g. input FGDB layer record) to another feature (e.g. master AGOL Feature Service layer record)?&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;Geometry copy - not feature copy - to avoid messing with: existing attributes (Object ID, GUID, create/edit name/date), nested relates, and dependent apps.&lt;/P&gt;&lt;P&gt;Currently, I'm tracing the "input" shapes by using the "Replace Geometry" and "Continue Feature" tools to updated the master feature record. This is tedious and error prone given complex shapes with up to 100+ multipart parts.&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is a python way to replace geometries but I don't know how to create a safe "press button" or copy/paste solution in ArcPro.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Nov 2021 19:49:40 GMT</pubDate>
    <dc:creator>Wolfgang_Grunberg_AZ_DFFM</dc:creator>
    <dc:date>2021-11-15T19:49:40Z</dc:date>
    <item>
      <title>ArcPro how to COPY multipart GEOMETRY between separate layers?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpro-how-to-copy-multipart-geometry-between/m-p/1117014#M47855</link>
      <description>&lt;P&gt;How can I copy and replace the multipart polygon GEOMETRY from one feature (e.g. input FGDB layer record) to another feature (e.g. master AGOL Feature Service layer record)?&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;Geometry copy - not feature copy - to avoid messing with: existing attributes (Object ID, GUID, create/edit name/date), nested relates, and dependent apps.&lt;/P&gt;&lt;P&gt;Currently, I'm tracing the "input" shapes by using the "Replace Geometry" and "Continue Feature" tools to updated the master feature record. This is tedious and error prone given complex shapes with up to 100+ multipart parts.&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is a python way to replace geometries but I don't know how to create a safe "press button" or copy/paste solution in ArcPro.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2021 19:49:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpro-how-to-copy-multipart-geometry-between/m-p/1117014#M47855</guid>
      <dc:creator>Wolfgang_Grunberg_AZ_DFFM</dc:creator>
      <dc:date>2021-11-15T19:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPro how to COPY multipart GEOMETRY between separate layers?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpro-how-to-copy-multipart-geometry-between/m-p/1117139#M47868</link>
      <description>&lt;P&gt;If the input and master layers have a common field:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;geometry_layer_name = "name_of_the_layer_with_the_right_geometry"
attribute_layer_name = "name_of_the_layer_with_attributes_and_wrong_geometry"
common_field = "name_of_the_common_field"

# this will change the geometry of the second layer's underlying data, so back it up!

active_map = arcpy.mp.ArcGISProject("current").activeMap
geometry_layer = active_map.listLayers(geometry_layer_name)[0]
attribute_layer = active_map.listLayers(attribute_layer_name)[0]

# read the correct geometries and save them in a dictionary
# {common_field_value: shape}
cursor = arcpy.da.SearchCursor(geometry_layer, [common_field, "SHAPE@"])
shapes = dict([row for row in cursor])

# loop through the second layer and update the geometries
updated_features = []
with arcpy.da.UpdateCursor(attribute_layer, [common_field, "SHAPE@"]) as cursor:
    for row in cursor:
        try:
            new_shape = shapes[row[0]]
            # only update if the geometry is different, fill the updated_features list
            if not new_shape.equals(row[1]):
                cursor.updateRow([row[0], new_shape])
                updated_features.append(row[0])
        except KeyError:
            print("No new geometry found for feature with {} = {}".format(common_field, row[0]))


# build an SQL query of the updated_features, depending on whether common_field is a text field or not
if updated_features and isinstance(updated_features[0], str):
    sql = "{} IN ('{}')".format(common_field, "', '".join(updated_features))
else:
    sql = "{} IN ({})".format(common_field, ", ".join([str(uf) for uf in updated_features]))
# print the SQL query
print("Updated the geometry of {} features:\n{}".format(len(updated_features), sql))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 07:22:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpro-how-to-copy-multipart-geometry-between/m-p/1117139#M47868</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-11-16T07:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPro how to COPY multipart GEOMETRY between separate layers?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpro-how-to-copy-multipart-geometry-between/m-p/1117299#M47885</link>
      <description>&lt;P&gt;Thanks Johannes for the code example!&lt;/P&gt;&lt;P&gt;I'm updating just one record in the master and the input has one record with random unrelated attributes. With enough skill, all doable in python. However, having to manually and correctly modify a script on every record update makes me very nervous. Have to look into the costs of developing an Add-In if there are no other options.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 16:01:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpro-how-to-copy-multipart-geometry-between/m-p/1117299#M47885</guid>
      <dc:creator>Wolfgang_Grunberg_AZ_DFFM</dc:creator>
      <dc:date>2021-11-16T16:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPro how to COPY multipart GEOMETRY between separate layers?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpro-how-to-copy-multipart-geometry-between/m-p/1117583#M47907</link>
      <description>&lt;P&gt;Ah. Then the script gets easier.&lt;/P&gt;&lt;P&gt;Select the feature you want to update in the master layer. If the input layer has more than one record, select the corresponding feature there, too. Run the script in the python window.&lt;/P&gt;&lt;P&gt;You just have to edit lines 1 and 2.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;input_layer_name = "name_of_the_input_layer"
master_layer_name = "name_of_the_master_layer"

active_map = arcpy.mp.ArcGISProject("current").activeMap
input_layer = active_map.listLayers(input_layer_name)[0]
master_layer = active_map.listLayers(master_layer_name)[0]

new_shape = [r[0] for r in arcpy.da.SearchCursor(input_layer, ["SHAPE@"])][0]
with arcpy.da.UpdateCursor(master_layer, ["SHAPE@"]) as cursor:
    for row in cursor:
        cursor.updateRow([new_shape])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 06:26:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpro-how-to-copy-multipart-geometry-between/m-p/1117583#M47907</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-11-17T06:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPro how to COPY multipart GEOMETRY between separate layers?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpro-how-to-copy-multipart-geometry-between/m-p/1175811#M55360</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled1.png" style="width: 660px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/41795i1C773CB769A8E6E9/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled1.png" alt="Untitled1.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled2.png" style="width: 660px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/41794i9EA9D979968D149D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled2.png" alt="Untitled2.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled3.png" style="width: 660px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/41793iE8B49D8A58C9D7F7/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled3.png" alt="Untitled3.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2022 00:26:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpro-how-to-copy-multipart-geometry-between/m-p/1175811#M55360</guid>
      <dc:creator>SepidehDadashi_DFFM_AZ</dc:creator>
      <dc:date>2022-05-20T00:26:57Z</dc:date>
    </item>
  </channel>
</rss>

