ArcGIS - How to copy and replace polygon (ONLY GEOMETRY) Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Is it possible to set the layer which the trace tool traces?Using arcpy.da.SearchCursor to script snapping one set of points to location of another set of points?How do I copy or edit a cell of attribute table and paste in text file?ArcGIS Find and Replace attribute search errorCopy Features (Data Management) and replace the new featuresLarge dataset, how to copy values between fieldsUsing Replace Geometry to replace selected feature with circle in ArcGIS Desktop?QGIS 2.10.1 Copy and Paste Problem - Attributes not showingHow to copy attributes after splitting polylines?Polygon to Polygon: new geometry, preserve attributesHow to copypaste selected field to other attribute table in ArcGIS 10.3?Creating new PostGIS table with records + geometries from another table?

Is the Standard Deduction better than Itemized when both are the same amount?

Generate an RGB colour grid

Using et al. for a last / senior author rather than for a first author

Why did the rest of the Eastern Bloc not invade Yugoslavia?

Identifying polygons that intersect with another layer using QGIS?

String `!23` is replaced with `docker` in command line

How to call a function with default parameter through a pointer to function that is the return of another function?

Can a USB port passively 'listen only'?

Why do people hide their license plates in the EU?

Why aren't air breathing engines used as small first stages

Align equal signs while including text over equalities

Extract all GPU name, model and GPU ram

Sci-Fi book where patients in a coma ward all live in a subconscious world linked together

Why did the IBM 650 use bi-quinary?

Seeking colloquialism for “just because”

How discoverable are IPv6 addresses and AAAA names by potential attackers?

Short Story with Cinderella as a Voo-doo Witch

Is there a (better) way to access $wpdb results?

What LEGO pieces have "real-world" functionality?

3 doors, three guards, one stone

How to find all the available tools in macOS terminal?

Are two submodules (where one is contained in the other) isomorphic if their quotientmodules are isomorphic?

Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?

Single word antonym of "flightless"



ArcGIS - How to copy and replace polygon (ONLY GEOMETRY)



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Is it possible to set the layer which the trace tool traces?Using arcpy.da.SearchCursor to script snapping one set of points to location of another set of points?How do I copy or edit a cell of attribute table and paste in text file?ArcGIS Find and Replace attribute search errorCopy Features (Data Management) and replace the new featuresLarge dataset, how to copy values between fieldsUsing Replace Geometry to replace selected feature with circle in ArcGIS Desktop?QGIS 2.10.1 Copy and Paste Problem - Attributes not showingHow to copy attributes after splitting polylines?Polygon to Polygon: new geometry, preserve attributesHow to copypaste selected field to other attribute table in ArcGIS 10.3?Creating new PostGIS table with records + geometries from another table?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








5















I have two layer (A, B). I need copy polygon from layer A and replace polygon in layer B, but only geometry. I want to preserve original attribute table from layer A.










share|improve this question
























  • I am confused. Are you wanting to copy geometry or attributes from A to B? What will be the difference between A and B?

    – Barbarossa
    Nov 25 '13 at 16:57











  • I am trying to copy a geometry from one table and paste it to another but it says insufficient permission. I only want to do it for only one mining application. I don't want to digitise the entire area because it will take

    – mbuyi
    Dec 8 '17 at 8:26


















5















I have two layer (A, B). I need copy polygon from layer A and replace polygon in layer B, but only geometry. I want to preserve original attribute table from layer A.










share|improve this question
























  • I am confused. Are you wanting to copy geometry or attributes from A to B? What will be the difference between A and B?

    – Barbarossa
    Nov 25 '13 at 16:57











  • I am trying to copy a geometry from one table and paste it to another but it says insufficient permission. I only want to do it for only one mining application. I don't want to digitise the entire area because it will take

    – mbuyi
    Dec 8 '17 at 8:26














5












5








5


1






I have two layer (A, B). I need copy polygon from layer A and replace polygon in layer B, but only geometry. I want to preserve original attribute table from layer A.










share|improve this question
















I have two layer (A, B). I need copy polygon from layer A and replace polygon in layer B, but only geometry. I want to preserve original attribute table from layer A.







arcgis-desktop copy






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '13 at 22:15









PolyGeo

54k1782246




54k1782246










asked Nov 25 '13 at 16:20









kocakkocak

2612




2612












  • I am confused. Are you wanting to copy geometry or attributes from A to B? What will be the difference between A and B?

    – Barbarossa
    Nov 25 '13 at 16:57











  • I am trying to copy a geometry from one table and paste it to another but it says insufficient permission. I only want to do it for only one mining application. I don't want to digitise the entire area because it will take

    – mbuyi
    Dec 8 '17 at 8:26


















  • I am confused. Are you wanting to copy geometry or attributes from A to B? What will be the difference between A and B?

    – Barbarossa
    Nov 25 '13 at 16:57











  • I am trying to copy a geometry from one table and paste it to another but it says insufficient permission. I only want to do it for only one mining application. I don't want to digitise the entire area because it will take

    – mbuyi
    Dec 8 '17 at 8:26

















I am confused. Are you wanting to copy geometry or attributes from A to B? What will be the difference between A and B?

– Barbarossa
Nov 25 '13 at 16:57





I am confused. Are you wanting to copy geometry or attributes from A to B? What will be the difference between A and B?

– Barbarossa
Nov 25 '13 at 16:57













I am trying to copy a geometry from one table and paste it to another but it says insufficient permission. I only want to do it for only one mining application. I don't want to digitise the entire area because it will take

– mbuyi
Dec 8 '17 at 8:26






I am trying to copy a geometry from one table and paste it to another but it says insufficient permission. I only want to do it for only one mining application. I don't want to digitise the entire area because it will take

– mbuyi
Dec 8 '17 at 8:26











4 Answers
4






active

oldest

votes


















7














I would consider using the arcpy.da.UpdateCursor and SHAPE@ token for representing the geometry object. First, you have iterate through the rows to find if the value in some unique ID field matches, and if yes > replace the source geometry with the target one.






share|improve this answer























  • Alex I am trying to perform the operation your describe using arcpy.da.UpdateCursor and SHAPE@, but with being new to python I can't get it to work. Could you show me an example code for this with "SITE_ID" as the matching field?

    – Homrich24
    Dec 15 '16 at 1:46












  • @Homrich24, sure! Please post a new question and me or some other person will provide an answer.

    – Alex Tereshenkov
    Dec 15 '16 at 7:20


















4














If you are only dealing with a few polygons, I would use the Replace Geometry tool on the Advanced Editing toolbar. See http://resources.arcgis.com/en/help/main/10.1/index.html#//01m80000001s000000



Alternately for a few polygons you could copy and paste the polygon(s) into layer B and then use the attribute transfer tool on the Spatial Adjustment toolbar to copy the attributes into the copied polygon; then delete the poly to be replaced.



But if you want to do this for all or many polygons and you have ArcInfo/Advanced, you could convert the affected layer B polygons to points inside the shape (and then later delete these polygons), convert the matching layer A polygons to lines, and then build polygons using the points as attributes. Check to make sure no point on the edge of one shape in B is not in the matching A. Add these new polygons to layer B. Use copies in case of mistake. My guess is Alex's answer is the most elegant, however.






share|improve this answer























  • You can speed up the manual process outlined here by using the Replace Geometry tool to draw a very simple rectangle around the new geometry without tracing every single one of its vertices. Then select the new geometry, hit the editor menu, go down to clip, then choose to preserve the area that intersects. Then you get all of the new geometry and preserve the attributes.

    – ndthl
    May 11 '15 at 9:07











  • This answer/tool worked great for me: I had a copy of the original polygon layer, which I made close to 300 polygon modifications (changing both attributes and polygon boundaries as well). Then I had to update my original layer (containing like 36.000 polygons), with the changes made in the copied layer. I used Replace Geometry and it did the job in a great/seamless manner. Good advice. Thanks!

    – Delonix R.
    Jun 14 '17 at 16:03


















2














As already mentioned you can use the da.UpdateCursor to update geometries. The geometries from A is stored in a Dictionary using the da.SearchCursor. The Dictionary is then used in the UpdateCursor to replace geometries where IDs match:



import arcpy

#Change to match your data:
arcpy.env.workspace = r'C:database.gdb'
A = 'featureclass1'
idfieldA = 'ID123'
B = 'featureclass2'
idfieldB = 'ID456'

#Build a dictionary with IDs as keys and geometries as value
geometries = key:value for (key,value) in arcpy.da.SearchCursor(A, [idfieldA, 'SHAPE@'])

#Empty list to store ids in B not found in A
notfound = []

#Update B with geometries from A where ID:s match
with arcpy.da.UpdateCursor(B, [idfieldB, 'SHAPE@']) as cursor:
for row in cursor:
try:
row[1] = geometries[row[0]]
cursor.updateRow(row)
except:
notfound.append(row[0])

print 'Found no id match and could not update geometry for IDs: ', notfound





share|improve this answer
































    0














    As stated there is the Replace Geometry Tool. You can also use copy/paste and another doc about copy/paste between databases. If you are comfortable with programing, the arcpy.da.search and update cursor can also do the trick.






    share|improve this answer























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "79"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f78541%2farcgis-how-to-copy-and-replace-polygon-only-geometry%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      7














      I would consider using the arcpy.da.UpdateCursor and SHAPE@ token for representing the geometry object. First, you have iterate through the rows to find if the value in some unique ID field matches, and if yes > replace the source geometry with the target one.






      share|improve this answer























      • Alex I am trying to perform the operation your describe using arcpy.da.UpdateCursor and SHAPE@, but with being new to python I can't get it to work. Could you show me an example code for this with "SITE_ID" as the matching field?

        – Homrich24
        Dec 15 '16 at 1:46












      • @Homrich24, sure! Please post a new question and me or some other person will provide an answer.

        – Alex Tereshenkov
        Dec 15 '16 at 7:20















      7














      I would consider using the arcpy.da.UpdateCursor and SHAPE@ token for representing the geometry object. First, you have iterate through the rows to find if the value in some unique ID field matches, and if yes > replace the source geometry with the target one.






      share|improve this answer























      • Alex I am trying to perform the operation your describe using arcpy.da.UpdateCursor and SHAPE@, but with being new to python I can't get it to work. Could you show me an example code for this with "SITE_ID" as the matching field?

        – Homrich24
        Dec 15 '16 at 1:46












      • @Homrich24, sure! Please post a new question and me or some other person will provide an answer.

        – Alex Tereshenkov
        Dec 15 '16 at 7:20













      7












      7








      7







      I would consider using the arcpy.da.UpdateCursor and SHAPE@ token for representing the geometry object. First, you have iterate through the rows to find if the value in some unique ID field matches, and if yes > replace the source geometry with the target one.






      share|improve this answer













      I would consider using the arcpy.da.UpdateCursor and SHAPE@ token for representing the geometry object. First, you have iterate through the rows to find if the value in some unique ID field matches, and if yes > replace the source geometry with the target one.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Nov 25 '13 at 16:56









      Alex TereshenkovAlex Tereshenkov

      26.4k135100




      26.4k135100












      • Alex I am trying to perform the operation your describe using arcpy.da.UpdateCursor and SHAPE@, but with being new to python I can't get it to work. Could you show me an example code for this with "SITE_ID" as the matching field?

        – Homrich24
        Dec 15 '16 at 1:46












      • @Homrich24, sure! Please post a new question and me or some other person will provide an answer.

        – Alex Tereshenkov
        Dec 15 '16 at 7:20

















      • Alex I am trying to perform the operation your describe using arcpy.da.UpdateCursor and SHAPE@, but with being new to python I can't get it to work. Could you show me an example code for this with "SITE_ID" as the matching field?

        – Homrich24
        Dec 15 '16 at 1:46












      • @Homrich24, sure! Please post a new question and me or some other person will provide an answer.

        – Alex Tereshenkov
        Dec 15 '16 at 7:20
















      Alex I am trying to perform the operation your describe using arcpy.da.UpdateCursor and SHAPE@, but with being new to python I can't get it to work. Could you show me an example code for this with "SITE_ID" as the matching field?

      – Homrich24
      Dec 15 '16 at 1:46






      Alex I am trying to perform the operation your describe using arcpy.da.UpdateCursor and SHAPE@, but with being new to python I can't get it to work. Could you show me an example code for this with "SITE_ID" as the matching field?

      – Homrich24
      Dec 15 '16 at 1:46














      @Homrich24, sure! Please post a new question and me or some other person will provide an answer.

      – Alex Tereshenkov
      Dec 15 '16 at 7:20





      @Homrich24, sure! Please post a new question and me or some other person will provide an answer.

      – Alex Tereshenkov
      Dec 15 '16 at 7:20













      4














      If you are only dealing with a few polygons, I would use the Replace Geometry tool on the Advanced Editing toolbar. See http://resources.arcgis.com/en/help/main/10.1/index.html#//01m80000001s000000



      Alternately for a few polygons you could copy and paste the polygon(s) into layer B and then use the attribute transfer tool on the Spatial Adjustment toolbar to copy the attributes into the copied polygon; then delete the poly to be replaced.



      But if you want to do this for all or many polygons and you have ArcInfo/Advanced, you could convert the affected layer B polygons to points inside the shape (and then later delete these polygons), convert the matching layer A polygons to lines, and then build polygons using the points as attributes. Check to make sure no point on the edge of one shape in B is not in the matching A. Add these new polygons to layer B. Use copies in case of mistake. My guess is Alex's answer is the most elegant, however.






      share|improve this answer























      • You can speed up the manual process outlined here by using the Replace Geometry tool to draw a very simple rectangle around the new geometry without tracing every single one of its vertices. Then select the new geometry, hit the editor menu, go down to clip, then choose to preserve the area that intersects. Then you get all of the new geometry and preserve the attributes.

        – ndthl
        May 11 '15 at 9:07











      • This answer/tool worked great for me: I had a copy of the original polygon layer, which I made close to 300 polygon modifications (changing both attributes and polygon boundaries as well). Then I had to update my original layer (containing like 36.000 polygons), with the changes made in the copied layer. I used Replace Geometry and it did the job in a great/seamless manner. Good advice. Thanks!

        – Delonix R.
        Jun 14 '17 at 16:03















      4














      If you are only dealing with a few polygons, I would use the Replace Geometry tool on the Advanced Editing toolbar. See http://resources.arcgis.com/en/help/main/10.1/index.html#//01m80000001s000000



      Alternately for a few polygons you could copy and paste the polygon(s) into layer B and then use the attribute transfer tool on the Spatial Adjustment toolbar to copy the attributes into the copied polygon; then delete the poly to be replaced.



      But if you want to do this for all or many polygons and you have ArcInfo/Advanced, you could convert the affected layer B polygons to points inside the shape (and then later delete these polygons), convert the matching layer A polygons to lines, and then build polygons using the points as attributes. Check to make sure no point on the edge of one shape in B is not in the matching A. Add these new polygons to layer B. Use copies in case of mistake. My guess is Alex's answer is the most elegant, however.






      share|improve this answer























      • You can speed up the manual process outlined here by using the Replace Geometry tool to draw a very simple rectangle around the new geometry without tracing every single one of its vertices. Then select the new geometry, hit the editor menu, go down to clip, then choose to preserve the area that intersects. Then you get all of the new geometry and preserve the attributes.

        – ndthl
        May 11 '15 at 9:07











      • This answer/tool worked great for me: I had a copy of the original polygon layer, which I made close to 300 polygon modifications (changing both attributes and polygon boundaries as well). Then I had to update my original layer (containing like 36.000 polygons), with the changes made in the copied layer. I used Replace Geometry and it did the job in a great/seamless manner. Good advice. Thanks!

        – Delonix R.
        Jun 14 '17 at 16:03













      4












      4








      4







      If you are only dealing with a few polygons, I would use the Replace Geometry tool on the Advanced Editing toolbar. See http://resources.arcgis.com/en/help/main/10.1/index.html#//01m80000001s000000



      Alternately for a few polygons you could copy and paste the polygon(s) into layer B and then use the attribute transfer tool on the Spatial Adjustment toolbar to copy the attributes into the copied polygon; then delete the poly to be replaced.



      But if you want to do this for all or many polygons and you have ArcInfo/Advanced, you could convert the affected layer B polygons to points inside the shape (and then later delete these polygons), convert the matching layer A polygons to lines, and then build polygons using the points as attributes. Check to make sure no point on the edge of one shape in B is not in the matching A. Add these new polygons to layer B. Use copies in case of mistake. My guess is Alex's answer is the most elegant, however.






      share|improve this answer













      If you are only dealing with a few polygons, I would use the Replace Geometry tool on the Advanced Editing toolbar. See http://resources.arcgis.com/en/help/main/10.1/index.html#//01m80000001s000000



      Alternately for a few polygons you could copy and paste the polygon(s) into layer B and then use the attribute transfer tool on the Spatial Adjustment toolbar to copy the attributes into the copied polygon; then delete the poly to be replaced.



      But if you want to do this for all or many polygons and you have ArcInfo/Advanced, you could convert the affected layer B polygons to points inside the shape (and then later delete these polygons), convert the matching layer A polygons to lines, and then build polygons using the points as attributes. Check to make sure no point on the edge of one shape in B is not in the matching A. Add these new polygons to layer B. Use copies in case of mistake. My guess is Alex's answer is the most elegant, however.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Nov 25 '13 at 17:49









      johnsjohns

      1,0171010




      1,0171010












      • You can speed up the manual process outlined here by using the Replace Geometry tool to draw a very simple rectangle around the new geometry without tracing every single one of its vertices. Then select the new geometry, hit the editor menu, go down to clip, then choose to preserve the area that intersects. Then you get all of the new geometry and preserve the attributes.

        – ndthl
        May 11 '15 at 9:07











      • This answer/tool worked great for me: I had a copy of the original polygon layer, which I made close to 300 polygon modifications (changing both attributes and polygon boundaries as well). Then I had to update my original layer (containing like 36.000 polygons), with the changes made in the copied layer. I used Replace Geometry and it did the job in a great/seamless manner. Good advice. Thanks!

        – Delonix R.
        Jun 14 '17 at 16:03

















      • You can speed up the manual process outlined here by using the Replace Geometry tool to draw a very simple rectangle around the new geometry without tracing every single one of its vertices. Then select the new geometry, hit the editor menu, go down to clip, then choose to preserve the area that intersects. Then you get all of the new geometry and preserve the attributes.

        – ndthl
        May 11 '15 at 9:07











      • This answer/tool worked great for me: I had a copy of the original polygon layer, which I made close to 300 polygon modifications (changing both attributes and polygon boundaries as well). Then I had to update my original layer (containing like 36.000 polygons), with the changes made in the copied layer. I used Replace Geometry and it did the job in a great/seamless manner. Good advice. Thanks!

        – Delonix R.
        Jun 14 '17 at 16:03
















      You can speed up the manual process outlined here by using the Replace Geometry tool to draw a very simple rectangle around the new geometry without tracing every single one of its vertices. Then select the new geometry, hit the editor menu, go down to clip, then choose to preserve the area that intersects. Then you get all of the new geometry and preserve the attributes.

      – ndthl
      May 11 '15 at 9:07





      You can speed up the manual process outlined here by using the Replace Geometry tool to draw a very simple rectangle around the new geometry without tracing every single one of its vertices. Then select the new geometry, hit the editor menu, go down to clip, then choose to preserve the area that intersects. Then you get all of the new geometry and preserve the attributes.

      – ndthl
      May 11 '15 at 9:07













      This answer/tool worked great for me: I had a copy of the original polygon layer, which I made close to 300 polygon modifications (changing both attributes and polygon boundaries as well). Then I had to update my original layer (containing like 36.000 polygons), with the changes made in the copied layer. I used Replace Geometry and it did the job in a great/seamless manner. Good advice. Thanks!

      – Delonix R.
      Jun 14 '17 at 16:03





      This answer/tool worked great for me: I had a copy of the original polygon layer, which I made close to 300 polygon modifications (changing both attributes and polygon boundaries as well). Then I had to update my original layer (containing like 36.000 polygons), with the changes made in the copied layer. I used Replace Geometry and it did the job in a great/seamless manner. Good advice. Thanks!

      – Delonix R.
      Jun 14 '17 at 16:03











      2














      As already mentioned you can use the da.UpdateCursor to update geometries. The geometries from A is stored in a Dictionary using the da.SearchCursor. The Dictionary is then used in the UpdateCursor to replace geometries where IDs match:



      import arcpy

      #Change to match your data:
      arcpy.env.workspace = r'C:database.gdb'
      A = 'featureclass1'
      idfieldA = 'ID123'
      B = 'featureclass2'
      idfieldB = 'ID456'

      #Build a dictionary with IDs as keys and geometries as value
      geometries = key:value for (key,value) in arcpy.da.SearchCursor(A, [idfieldA, 'SHAPE@'])

      #Empty list to store ids in B not found in A
      notfound = []

      #Update B with geometries from A where ID:s match
      with arcpy.da.UpdateCursor(B, [idfieldB, 'SHAPE@']) as cursor:
      for row in cursor:
      try:
      row[1] = geometries[row[0]]
      cursor.updateRow(row)
      except:
      notfound.append(row[0])

      print 'Found no id match and could not update geometry for IDs: ', notfound





      share|improve this answer





























        2














        As already mentioned you can use the da.UpdateCursor to update geometries. The geometries from A is stored in a Dictionary using the da.SearchCursor. The Dictionary is then used in the UpdateCursor to replace geometries where IDs match:



        import arcpy

        #Change to match your data:
        arcpy.env.workspace = r'C:database.gdb'
        A = 'featureclass1'
        idfieldA = 'ID123'
        B = 'featureclass2'
        idfieldB = 'ID456'

        #Build a dictionary with IDs as keys and geometries as value
        geometries = key:value for (key,value) in arcpy.da.SearchCursor(A, [idfieldA, 'SHAPE@'])

        #Empty list to store ids in B not found in A
        notfound = []

        #Update B with geometries from A where ID:s match
        with arcpy.da.UpdateCursor(B, [idfieldB, 'SHAPE@']) as cursor:
        for row in cursor:
        try:
        row[1] = geometries[row[0]]
        cursor.updateRow(row)
        except:
        notfound.append(row[0])

        print 'Found no id match and could not update geometry for IDs: ', notfound





        share|improve this answer



























          2












          2








          2







          As already mentioned you can use the da.UpdateCursor to update geometries. The geometries from A is stored in a Dictionary using the da.SearchCursor. The Dictionary is then used in the UpdateCursor to replace geometries where IDs match:



          import arcpy

          #Change to match your data:
          arcpy.env.workspace = r'C:database.gdb'
          A = 'featureclass1'
          idfieldA = 'ID123'
          B = 'featureclass2'
          idfieldB = 'ID456'

          #Build a dictionary with IDs as keys and geometries as value
          geometries = key:value for (key,value) in arcpy.da.SearchCursor(A, [idfieldA, 'SHAPE@'])

          #Empty list to store ids in B not found in A
          notfound = []

          #Update B with geometries from A where ID:s match
          with arcpy.da.UpdateCursor(B, [idfieldB, 'SHAPE@']) as cursor:
          for row in cursor:
          try:
          row[1] = geometries[row[0]]
          cursor.updateRow(row)
          except:
          notfound.append(row[0])

          print 'Found no id match and could not update geometry for IDs: ', notfound





          share|improve this answer















          As already mentioned you can use the da.UpdateCursor to update geometries. The geometries from A is stored in a Dictionary using the da.SearchCursor. The Dictionary is then used in the UpdateCursor to replace geometries where IDs match:



          import arcpy

          #Change to match your data:
          arcpy.env.workspace = r'C:database.gdb'
          A = 'featureclass1'
          idfieldA = 'ID123'
          B = 'featureclass2'
          idfieldB = 'ID456'

          #Build a dictionary with IDs as keys and geometries as value
          geometries = key:value for (key,value) in arcpy.da.SearchCursor(A, [idfieldA, 'SHAPE@'])

          #Empty list to store ids in B not found in A
          notfound = []

          #Update B with geometries from A where ID:s match
          with arcpy.da.UpdateCursor(B, [idfieldB, 'SHAPE@']) as cursor:
          for row in cursor:
          try:
          row[1] = geometries[row[0]]
          cursor.updateRow(row)
          except:
          notfound.append(row[0])

          print 'Found no id match and could not update geometry for IDs: ', notfound






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 8 '17 at 9:32

























          answered Dec 8 '17 at 9:10









          BERABERA

          17.2k62044




          17.2k62044





















              0














              As stated there is the Replace Geometry Tool. You can also use copy/paste and another doc about copy/paste between databases. If you are comfortable with programing, the arcpy.da.search and update cursor can also do the trick.






              share|improve this answer



























                0














                As stated there is the Replace Geometry Tool. You can also use copy/paste and another doc about copy/paste between databases. If you are comfortable with programing, the arcpy.da.search and update cursor can also do the trick.






                share|improve this answer

























                  0












                  0








                  0







                  As stated there is the Replace Geometry Tool. You can also use copy/paste and another doc about copy/paste between databases. If you are comfortable with programing, the arcpy.da.search and update cursor can also do the trick.






                  share|improve this answer













                  As stated there is the Replace Geometry Tool. You can also use copy/paste and another doc about copy/paste between databases. If you are comfortable with programing, the arcpy.da.search and update cursor can also do the trick.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Apr 9 at 16:38









                  SteveSteve

                  1,066717




                  1,066717



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f78541%2farcgis-how-to-copy-and-replace-polygon-only-geometry%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      រឿង រ៉ូមេអូ និង ហ្ស៊ុយលីយេ សង្ខេបរឿង តួអង្គ បញ្ជីណែនាំ

                      QGIS export composer to PDF scale the map [closed] Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Print Composer QGIS 2.6, how to export image?QGIS 2.8.1 print composer won't export all OpenCycleMap base layer tilesSave Print/Map QGIS composer view as PNG/PDF using Python (without changing anything in visible layout)?Export QGIS Print Composer PDF with searchable text labelsQGIS Print Composer does not change from landscape to portrait orientation?How can I avoid map size and scale changes in print composer?Fuzzy PDF export in QGIS running on macSierra OSExport the legend into its 100% size using Print ComposerScale-dependent rendering in QGIS PDF output

                      PDF-ში გადმოწერა სანავიგაციო მენიუproject page