I have created a relationship between two feature classes(one to many) and i want to have the sum of a field in tableB(many) into a cell in TableA (one), TableA is states and tableB is roads within the state, so i want the sum of roads in each state(in a field in tableA). I have created one to many relationship class between two feature classes (not shapefile) within the same database, these feature classes have attribute tables (A, one and B, many). So i want sum of a field(colunm) from tableB into tableA. I hope it is clear know.
-
Welcome to GIS SE! As a new user please take the tour to learn about our focused Q&A format. What have you tried? Can you please edit your question to include a sample of each dataset, and how they relate to each other?– Midavalo ♦Commented Apr 6, 2017 at 17:05
-
Also perhaps include some info about what format your data are in, ie shapefile, database, etc. That may help give options to solve the problem.– Get SpatialCommented Apr 6, 2017 at 17:07
-
By relationship table do you mean relationship class?– PolyGeo ♦Commented Apr 6, 2017 at 19:49
1 Answer
You won't be able to store a new attribute in the relationship class called SumRoadLength
which will contain the sum of the length or other attribute from the Roads
feature class.
Take a look at this page: Relationship class properties. You can copy-paste attributes between the origin-destination however there is no concept of calculated or computed fields and triggers that you have in a DBMS. In other words, editing the length of a road in a particular state won't update the SumRoadLength
field in the relationship class.
I don't know other moving parts of your workflow, but I'd recommend taking a look at ModelBuilder or Python if you would like to automate the workflow of updating the information between feature classes. You could also manually run the Summary Statistics GP tool. Here is a sample of calculating the total population of all cities within every state.
Then join the output table to your states feature class using the Add Join or Join Field GP tools.
-
Thanks Mr.Alex, it worked for me using model builder, but the only problem is that i should delete the sum field every time i want to run the model (update it),(another field for the sum is joining to the state table), any way its the best solotion so far. Commented Apr 7, 2017 at 7:10
-
Good. You don't have to delete the field every time you need to do update. Just add join for the field with another name, calculate existing field (sum_length) and then remove the join. Commented Apr 7, 2017 at 8:00