Saturday, 14 November 2015

merge - Combining touching polygons, keeping all attributes from Class "A" feature, using ArcGIS Desktop?


How to automatically merge polygons sharing a common boundary, keeping all attributes from class "A" features?


Interactively I would do this in an edit session by:




Repeat for features of Name "Two", "Three", ...


Dissolve solution from How to combine adjacent polygons sharing similar trait into single polygon? doesn't work because we need to keep other attributes which differ. In other words:



  • Dissolve/merge touching polygons where geometry [Name] is identical

  • Keep attributes from polygon with [Class] A (if multiple Class A's, ok to just keep first one)

  • Discard attributes from other features


Before and after example


Annotated table, what to keep and discard




Answer



I would create two copies of the layer for this feature class. In one layer I would select everything. In the other layer I would select just the polygons with a Class of "A". I would use Spatial Join using the layer with all features selected as the target and the layer with just Class A features as the Join layer. I would use the keep all target features option and the One to One option.


The output will have duplicate fields, Select all records where the Name and Name_1 fields contain the same values. This will be the set of all the features that touched a Class A feature and had a matching Name value. Calculate the Class field of the Target to be "A". Calculate over the Code_1 and waterDefinition_1 fields into the Code and waterDefinition fields to set these values to match the value of the touching Class A feature.


Now you can Dissolve all of the features and use all of the target fields as Dissolve fields (Not the fields ending in _1) to preserve the unique attribute cases. Uncheck the Create Multi-part feature option. If a feature was not touched by a Class A feature it will have its original attributes. Merge of these features would only occur if they were touching features that had the same attribute values that are not Class A attributes. However, all features that touched a Class A feature will now be merged together and have the Class A attributes.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...