0

I have layer "A" and layer "B". Layer "A" has polygon objects and unique ID for every object in attribute table. Layer "B" has some polygon objects from layer "A", but those polygons have been changed, unique ID is not changed. How can I update layer "A" polygon objects from layer "B". As I say, those objects share same unique ID.

  • Are you interested in updating Layer's "A" attributes or geometry or both? Do you want to do this manually or by using a script/custom tool? – Alex Tereshenkov May 26 '14 at 9:03
  • I am interested updating layers "A" geometry only. I am doing this manually by editing vertexes, but I want to do it automaticly since I have a lot of objects to reshape. – risk_ltu May 26 '14 at 9:57
  • To avoid confusion about the version of any product from the ArcGIS Platform that you are using it is best to always mention it in the body of your Question. Not everybody (re-)reads the title and tags so having them there only is not enough. – PolyGeo May 27 '14 at 1:36
1

I am not aware of any core GP tool that would do that for you, so I would go for an ArcPy solution by using cursors (available since 10.1):

import arcpy
to_update_lyr = r"C:\GIS\Temp\test.gdb\LayerA"
edited_lyr = r"C:\GIS\Temp\test.gdb\LayerB"
fields = ['UniqueID','SHAPE@']

with arcpy.da.SearchCursor(edited_lyr,fields) as search_cursor_lyr:
    for edited_feature in search_cursor_lyr:
        with arcpy.da.UpdateCursor(to_update_lyr,fields) as upd_cursor_lyr:
            for to_update_feature in upd_cursor_lyr:
                if edited_feature[0] == to_update_feature[0]:
                    to_update_feature[1] = edited_feature[1]
                    upd_cursor_lyr.updateRow(to_update_feature)
  • Thank you! I did not found any tool too. Geoprocessing tools just simple can't do that :) – risk_ltu May 26 '14 at 10:47
  • Hope you are able to understand the code and modify the paths to data and the unique ID field name. Refer to the Help page, there are some samples and description on usage there. – Alex Tereshenkov May 26 '14 at 10:51
  • I understood the code. Just did'nt know that field SHAPE@ exists as one object. I will look in the help page for it. – risk_ltu May 26 '14 at 10:57
  • 1
    I have just re-read the post name itself and noticed you are on 10.0 (no information on this was in the question text body itself). The code I've published will work only for 10.1+, my bad. – Alex Tereshenkov May 26 '14 at 10:59
  • 1
    This code will not work if you don't have ArcGIS 10.1+ installed on your machine. This is because it uses a cursor from a new module, Data Access, which became part of arcpy site package in 10.1. In 10.0, you are supposed to use "regular" cursors. You don't need to use ArcMap for executing Python scripts; since this code worked for you, this means you have ArcGIS 10.1+ installed on your machine. – Alex Tereshenkov May 26 '14 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.