A generic tool or model to write and combine the values of multiple fields on one other field

2857
25
02-11-2018 04:27 AM
FatinRimawi
Occasional Contributor

Hi All,

 

I have 2 feature classes which have attribute tables as following:

Feature 1:

X

T1

Y

T2

Z

T3

K

T4

Feature 2:

X, Y, Z, K

???

 

I am wondering if there is a methodology or tool that can help me in combining many fields and the result can be written in a new field as following:

X, Y, Z, K

T1,2,3,4

Kindly notice the following screenshot too.

Thank you in Advance

Fatin Rimawi

25 Replies
RichardFairhurst
MVP Honored Contributor

I want to add that in general I rarely abandon data at a fine grade level in favor of maintaining it only at an aggregated level, especially if my organization has access to or is responsible for authoritative data at the fine grade level.  Aggregation is a one way street.  You can easily and quickly generalize and aggregate from fine grade data anytime you want and achieve different levels of understandings of your data if it has a well defined relational structure, but it is impossible to recreate fine grade data directly from generalized or aggregated data once the relationships have been collapsed into a single simplified form.

The trajectory of my organization is toward expanding our access to ever finer levels of detail in our authoritative data and improving the spatial representation of that data so that we can integrate it into ever more detailed analysis through on the fly or daily aggregation via scripts.. As a consequence in the last two years the data I work with has gone from a few thousand records into the millions.  However, by setting up a good relational design and learning how to exploit it through joins, relates and scripts, now that I'm past the initial design phase the amount of time I spend maintaining the data has dropped while at the same time the number of outputs I can derive from it keeps expanding.

RandyBurton
MVP Alum

Not knowing your intended use of feature2, I thought having an option to average x,y coordinates might be of interest although keeping the point of the matched community in the Mutual field would probably be your preferred choice. 

I agree with rfairhur24‌'s comments on aggregating data.  Creating the second feature can help you understand the data in feature1, it may help you find data errors, but it should not be a replacement.  Hope this helps.

FatinRimawi
Occasional Contributor

Thank you Randy and Richard. I really appreciate your effort on this.

It's my first time that I am dealing  with ArcMap scripts, and yeah it's my fault that I did not show the real data relations from the beginning.I thought that graduating in problem may be much better.

Thank you for your understanding.

Fatin Rimawi

0 Kudos
RandyBurton
MVP Alum

Glad to help, and good luck with your project.

0 Kudos
BlakeTerhune
MVP Regular Contributor

Assuming the list of communities in FC2 is always comma separated, give this a try. I have not tested this and I may have missed some crucial info in your discussion with Richard Fairhurst.

# Local variables
fc1 = r"C:\myDB\FC1"
fc2 = r"C:\myDB\FC2"

# Read all of FC1 into dictionary in memory
## Ensure that all community values are unique in FC1
fc1_fields = ["community", "ref"]
fc1 = {community: ref for community, ref in searchCursor(fc1, fc1_fields)}

# If necessary, start edit session on FC2 to update it
fc2_fields = ["communityGroup", "refGroup"]
with updateCursor(fc2, fc2_fields) as fc2_cursor:
    for fc2_communityGroup, fc2_refGroup in fc2_cursor:
        # Create list of ref values from FC1 for the group of communities listed in FC2
        refGroup = []
        for community in fc2_communityGroup[0].split(","):
            refGroup.append(fc1[community])  ## Will error here if the community is not found in FC1
        # Create the comma separated list of ref values and update the row in FC2
        fc2_row[1] = ",".join(refGroup)
        fc2_cursor.updaterow(fc2_row)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
FatinRimawi
Occasional Contributor

Thank you Blake for your input, it will see how to implement this on my db.

Best,

Fatin

0 Kudos