How to calculate "Statistics" into a new field

372
7
07-21-2011 07:03 AM
JanKorbel
New Contributor
Hello,
I've come across this problem in model builder:
I have a polygon FeatureClass (FC) of cities, and table related to that FC (containing occurences of names by cities) in a many-to-one relationship (one city has many records from the table) and I've built a model, that:

- first of all, makes a query table from the cities FC and the related table, selecting specific records and exporting the resulting polygon FC into geodatabase.
- then aggregates these cities by Dissolve tool to a higher level of municipal hierarchy (NUTS2, NUTS3...) BUT:
  After the "Make Query Table" tool, I can summarize the occurences of chosen name by simply clicking on the field "name_occurence" and choosing "Statistics" I understand that. But is there a way how to add THIS number into new field to the table? Each record would have a new field named like "Name_total" and it would be the same number for all records... This is need for further calculations and it would be used as a constant in a formula...

I know which tool calculates such statistics, so when formulated in another way:
   How can I populate a new field within my FC with the result of "Summary statistics" tool upon  
   that table with the "name_occurence" field?

Thanks in advance for any help...
0 Kudos
7 Replies
JanKorbel
New Contributor
P.S.: Im working with ArcGis 9.3 😉
0 Kudos
DanLee
by Esri Regular Contributor
Esri Regular Contributor
Have a look of the Join Field tool. Hope you can figure out what fields to use to get the statistic value fields to the FC.

Regards,
0 Kudos
JanKorbel
New Contributor
The summary statistics tool makes a table with only one row. (see the thumbnail). Is "Join Field" tool capable of joining this field to all records in another table? (I don't have access to ArcInfo right now so is there a way how to manage it easily in ArcView only?)
0 Kudos
DanLee
by Esri Regular Contributor
Esri Regular Contributor
With ArcView license, you can try the following:
1.  Use the Add Field tool to add necessary fields one by one to your input FC.
2.  Use the Add Join tool to join your input FC with a table that contains fields you want to transfer to the input FC. The join is based on a common field from each table.
3.  Now if you open the input FC table you should see all fields from the input FC and from the joining table.
4.  Use the Calculate Field tool to calculate one of the added fields with the values from a field of the joining table. You would need to repeat this step for every field you need to calculate/transfer.
5.  Use the Remove Join tool to remove the join when finished.

The Join Field tool conveniently combines the above steps into one. Hope you will have access to it in the future.

I am not completely clear about how your FC and the related table are and what statistics you are trying to analyze and join to input FC. If you like, you can post a sample data and describe the specific cases. I or other people can have a look.

Regards,
0 Kudos
JanKorbel
New Contributor
I realized, that I ve probably misinterpreted my situation... I m attaching PScreen of my model in the thumbnail... It makes a query table from polygon cities and table of surnames with the same "City_ID" field (related together by that field). Then I dissolve this layer by counties, adding the total sum of occurences by county (by setting parametr "Statistic field" and SUM type)... And I need THIS number (lets call it total number of surnames), to be put into a new field, as a constant. I would then type "calculate field" formula like: [stats]=[Sum_of_all_occurences_by_county]/[total_number_of_surnames] OR, I think, it could be also managed by setting that number into a variable, but dont know how to do that... (=how can I set a variable as a constant, that is a SUM of a field from another table from the model? )

Thanks 4 answer, JOHN
0 Kudos
DanLee
by Esri Regular Contributor
Esri Regular Contributor
Thanks for providing the model image. It seems you want to get the surname count for each city and then use that for further analysis. Dissolve tool is the right way to do it, but unfortunately there is a known bug in the calculation of the statistics that is pending for a fix in ArcGIS 10.1.

It is possible to work around this using the Statistics tool, which returns FREQUENCY (like count) for the specified field. It may be a bit tricky in getting the count back to your city FC or other data. If you are willing to share a sample data, that would help us understand exactly what's going on and perhaps how to solve the problem.

Thanks,
0 Kudos
JanKorbel
New Contributor
Here I attach a sample database. Contains a sample of cities, and sample of name table and sample toolbox as I created and besides the problem described should work well... I hope it will help.

JOHN
0 Kudos