Select to view content in your preferred language

Dissolve/ based on condition

1364
9
02-18-2020 10:33 PM
HushamMohamed
Regular Contributor

Hello, 

I would like to dissolve large  polygon feature data set(25000 units) based on 2 conditions:

1- by attribute value partially matched,  (UNIT field)  

for example

idUnit 
1

   CLAY BROWN UNIT 2

2

   CLAY BROWN UNIT 3

3

   CLAY BROWN UNIT 4 sub unit 6

4

   CLAY BROWN UNIT 5

2- only adjacent polygon should be dissolved. ( warning topology is not clean 100% , small gaps may appear)

example only rows 1,2,3 are adjacent polygon.

I would appreciate any suggestion. 

Thank you

0 Kudos
9 Replies
DavidPike
MVP Frequent Contributor

Hi,

The dissolve will only dissolve adjacent features so condition 2 will be met anyway.

Regards gaps I would look at the integrate tool but be warned this will alter the existing data. I highly recommend making a copy before u do anything with it. It will also probably destroy and topology u have set up.

If u mean a partial field match I would probably add a new field such as higher level soil unit etc. And run a field calculator with a python code block to get the matches. I can write this when I get some time

0 Kudos
HushamMohamed
Regular Contributor

Thank for your your helpful information, 

The dissolve will only dissolve adjacent features so condition 2 will be met anyway.

Yes  I mean partial field match, from the example table (Clay Brown Unit) is partial match. another Example 

1- East Soil corrected 6th addition

2- East Soil corrected 5th addition

3- East Soil corrected 5th sub plat

only 1,2 should be dissolved.

 I would love to get that python script, to test,  

Thank you.

0 Kudos
HushamMohamed
Regular Contributor

defining multiple flags  in code block is a challenge, do I need to use regex. 

0 Kudos
DavidPike
MVP Frequent Contributor

How many entries are there to match to? If you list them I'll put them in the code to match. If theres hundreds I'll think of a better solution

0 Kudos
HushamMohamed
Regular Contributor

Thanks,  I am afraid they are  hundreds. I have 25000 records, (10 feature classes).

0 Kudos
DavidPike
MVP Frequent Contributor

Is there an identifiable pattern to break/group the string by? If not I cant really see a solution.

0 Kudos
HushamMohamed
Regular Contributor

Yes that is the problem, there is no identifiable pattern, 

Thank you very much.

0 Kudos
DanPatterson_Retired
MVP Emeritus

If there is no pattern, you may have to break them into groups and process accordingly.  Sometimes there is no one-solves-all.  You indicate that you have 10 featureclasses but 25000 records.  It appears you are looking for a substring within a string.  If it were you could use that information to parse the data first prior to determining whether to dissolve.

cases = ['East Soil corrected 6th addition',
         'East Soil corrected 5th addition',
         'East Soil corrected 5th sub plat']

for c in cases:
    if 'East Soil corrected' in c and 'addition' in c:
        print("dissolve")
    else:
        print("don't dissolve")
        
dissolve
dissolve
don't dissolve
0 Kudos
HushamMohamed
Regular Contributor

Thank you, using Case statement is not an option,  keeping up with it for anything new may be a pain. 

0 Kudos