AnsweredAssumed Answered

Automation of multiple feature mergers via python script // ModelBuilder

Question asked by student_93 on Aug 19, 2018
Latest reply on Aug 26, 2018 by student_93

Dear community,

I have a district area FC (DTR, polygons) with attributes containing the information to which sales area (SA, polygons) a DTR belongs (+ fields with info about the name of the responsible sales person, the higher organisation level (HQ) etc.). A SA consists of multiple DTR. SAs can overlap. Within the time some DTRs were split into more DTRs but they still have the same DTR-ID, which means in the attribute table they are features with same DTR-IDs but different SA-IDs.

What I want to do is to union all of the DTR-features with identical DTR-IDs AND duplicate these geometries based on the number of SA-IDs AND assign to each of the new created merged DTR-feature all of the attributes of the original DTRs.

Maybe this pic can help to better understand the problem (only an example to demonstrate the problem)

Left: 7 different DTR-features (all have the same DTR-ID) with 5 different SA-IDs (01,02,…,05). The amount of SA-IDs within a DTR-feature represents the number of DTR-features with IDENTICAL geometries (e.g. 01 – 02 or 04-05-03), which means they overlap (the same below).

The only idea I have so far:

Select all DTR-features where the number of DTR-IDs > 1 (in other words, identify duplicates) and where the geometries AREN´T identical (I only want to find DTR-features which are partly overlapped by SAs features). For this I added 2 new fields (number of DTR-IDs duplicates and number of shape area duplicates) (features with same shape areas are duplicates). To calculate the number of duplications for each parameter I used this python scrpit (see calculating duplicates in field calculator using python).

After that I created the selection where number of DTR-ID duplications <> number of shape areas duplications which means I selected DTR-features which are overlapped by more SAs. I created a new FC (exported the selected features), ran the DISSOLVED tool (for DTR-ID), merged the dissolved FC with the FC of the exported duplications, than created copies of the dissolved DTR features based on the number of SA-IDs within the same DTR and merged these copies to the features which have the same DTR-ID but different SA-IDs (editor modus). In the end I can delete duplications in my original FC and replace them with these features.

Do you have any idea how to automatize this process? My FC has over 40,000 features and over 5,000 have the same DTR-IDs, which means SAs in these DTRs are overlapping. It would suffice to automatize only the last part of the process (copy creation of the dissolved and already merged (with the exported FC) features and their mergers to the DTR-features with different SA-IDs.

Python / ModelBuilder:

Create copies of dissolved DTR-features based on the number of features with the same DTR-ID

Merge each of these copies with all of the DTR-features with identical DTR-IDs (to each SA-ID).


Thank you in advance.