# Calculating and outputting max and average distance from point to points and output to table?

I have two point layers. One contains nest locations. The other contains movement points for the individuals being tracked. Both tables have a individual id parameter (one nest per id, many movement points per id).

I want to create a script (ModelBuilder preferred) that will generate a table (or update the nest table) to show the maximum distance and average distance between an individuals nest and the movement points from the other table.

So far I've tried using the PointDistance tool to create a table of distances from the nest to the points. Then I've had to manually get the max and average. As I have to rerun this often, I'd like to have the script automatically get the max and average and update the table or create a new table with one row per nest ID showing the max and averages.

The first image is a basic table layout and what I'd like in the output. There is really no relevant data in the tables other than the ID for the individual. I'm also including an image showing a sample nest point (in green) with the movement points for that nest ID.  To get the max and average the tool to include in your model will be Summary Statistics:

Calculates summary statistics for field(s) in a table.

...

Available statistics types are:

• SUM—Adds the total value for the specified field.
• MEAN—Calculates the average for the specified field.
• MIN—Finds the smallest value for all records of the specified field.
• MAX—Finds the largest value for all records of the specified field.
• RANGE—Finds the range of values (MAX minus MIN) for the specified field.
• STD—Finds the standard deviation on values in the specified field.
• COUNT—Finds the number of values included in statistical calculations. This counts each value except null values. To determine the number of null values in a field, use the COUNT statistic on the field in question, and a COUNT statistic on a different field which does not contain nulls (for example, the OID if present), then subtract the two values.
• FIRST—Finds the first record in the Input Table and uses its specified field value.
• LAST—Finds the last record in the Input Table and uses its specified field value.
• I'm not sure that is what I need. What would be in input to Summary Statistics? I have two point layers and that tool looks like it just summarizes a single table. – danahart Oct 24 '16 at 4:12
• The PointDistance tool I've tried gets the values but they output into a table for each feature. I want to capture the MEAN and MAX distance from each nest point to the sample points and output those two values to a table. The output table would have one row for each nest and a column for MEAN and MAX at least. Preferably I'd like to do this all in one script. – danahart Oct 24 '16 at 4:15
• The Summary Statistics tool is the tool you want. After you have calculated the distance using the Point Distance tool. You need to specify a Case Field which would be your individual_ID field. Running this tool with Mean and Max selected will calculate the mean and max for each individual. – Fezter Oct 24 '16 at 4:54
• Ok. I'm starting to follow now and have it generating output. The problem now is that it is generating the PointDistance from each Nest to all MovementPoints. I want it to only use the MovementPoints whose ID match the Nest. In the example image, it is currently calculating the distance from Nest a1 to all movement points (a1, a2, and a3). I want only the distance from nest a1 to movement point a1, and then a2 to a2, etc. Maybe I need to iterate through a query for each NestID? But then I'd get a bunch of output tables when I just want one. – danahart Oct 24 '16 at 5:23
• I think you should describe where you are now stuck as a new question. – PolyGeo Oct 24 '16 at 6:36