Merge/dissolve 2 features in same feature class where field A matches field B

358
5
11-04-2021 01:30 PM
Labels (2)
JeffThomasILM
Occasional Contributor II

I apologize if this question has been asked & answered before, but it's hard to search for the concept. 

I need to merge/dissolve features where the value in Field A for Feature 1 matches the value in Field B for Feature 2. Much like an attribute join, except they're all in the same feature class. I'd like the result to be a new feature class, leaving the original unchanged. I'm trying to figure out if this can be done with geoprocessing tools or if it will require a Python cursor. Thanks!

5 Replies
DanPatterson
MVP Esteemed Contributor

why not just query for field A == field B, then if there are selected records, export the selection to a new featureclass, make sure you have the featureclass selected in the TOC and data export.  If you do if from the table, you will just get the table exported


... sort of retired...
0 Kudos
JeffThomasILM
Occasional Contributor II

There will be dozens or hundreds of A==B feature pairs, so I need to create a tool that iterates over each feature in the feature class. Also, I don't think what you described would dissolve their geometries?

0 Kudos
DanPatterson
MVP Esteemed Contributor

Ahhh important information.

You will have to the query within an edit session and "union" the resulting geometries before moving on to the next query.  Some partial examples in the help documentation in and around this topic

Editor—ArcGIS Pro | Documentation

PS do it on a copy


... sort of retired...
0 Kudos
JeffThomasILM
Occasional Contributor II

Thank you, that sounds like a step in the right direction. However, I'm far from figuring out how to do this. I'm not even sure how to write a query to match multiple features in the same FC where FieldA==FieldB. 

Here's what I'm trying to do. I have a bunch of features in a FC. Every feature has a case number (field A). Some of them also have a related case number (field B). I want to merge features that have related case numbers with their related cases (field B == field A, retaining the latter features' attributes). To make things more interesting, case numbers are not unique identifiers, so I also need the feature type (field C) to match on all features being merged (that's a straightforward field C == field C). There are more details, but I'm trying to boil this down as much as possible in the hopes that someone can point me in the right direction. Thanks!

0 Kudos
JeffThomasILM
Occasional Contributor II

I found a workaround - a "cheat" - to do what I need: create a copy of the feature class, then overwrite the main case (field A) with the related case (field B), where the related case is not null. Then it's a simple, normal dissolve geoprocessing task on field A (and field C). While it's not quite how I intended to use my data and I've had to alter it a bit to accommodate this method, it works.

But... I'm still interested to know how to find where Feature 1, Field A == Feature 2, Field B in the same feature class. Basically, joining a table to itself. I know SQL can do that, though I was envisioning (and have now avoided) a messy scenario.

0 Kudos