How to calculate distance of multiple points?

12792
24
08-21-2017 11:11 AM
JoseBarrios2
New Contributor

Need help on how to calculate distance of multiple points. I have two layers : an input feature(office) and near feature ( projects). I want to know the distance of the projects for each office. The near tool won't work  (It calculate the distance to all points)  unless  I run the tool for each office...any ideas?

Thanks,

0 Kudos
24 Replies
JoshuaBixby
MVP Esteemed Contributor

No better time to learn Python than the present.  There is no pre-built tool that will accomplish what you are after, but what you are after should be fairly straightforward to script.  If you could provide some more specifics about your data files, GeoNet users could likely give specific examples to try.

0 Kudos
JoseBarrios2
New Contributor

Hello Joshua,

You are correct. It is a great tool and I am learning Python but it may take a while before I am capable of compiling a tool that can do all what I need. Here is how my data look like: I have two shp. layers (both points).  One layer is for the office with two fields - office_Name and orgCode (total 128 records); The other layer contain the projects (7000 records)  with 4 fields:  Project_Name,.. Project_ID, ...Project_Type and the common field key "orgCode" that identify the office. The projects cover the entire southeast of US and the Caribbean. Some offices are very close and some very far and there is no search radius or boundary that I can use to limit the distance for targeting the features. 

 Basically my Input feature is the Office layer and my near feature is the Projects. I am trying to write a simple script that do what I am doing manually:

1. select the office record by orgCode

2. find the common key on "projects" table and select the records

3. run the point distance tool on selected records

4. select the distance field and run the summary for min, max and mean distance

5. save the table with the stat.

6. look for next office record and repeat the process

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Your data set isn't that large.  I would go with: 1) Generate Near Table—Help | ArcGIS Desktop, 2) join each shape file/layer to the new table based on the unique identifiers (not orgCode), 3) select all records where orgCode from the 2 layers don't match, 4) delete selected records to get only distances for projects from relevant office.

I suspect the Generate Near Table will complete in seconds for a data set of this size.  If the data set were extremely large, it might make sense to optimize the workflow to work on subsets of data, but that would be overkill in this case.

0 Kudos
JoseBarrios2
New Contributor

I'm not clear what do you men by running the near table tool. If I do that, it would create 896,000 records...it basically measure the distance of the 7000 records to each office. On not clear how I will join the tables!!

0 Kudos
ChrisDonohue__GISP
MVP Alum

It is not immediately obvious, but with Generate Near Table one joins the resultant table back to the original inputs based on the Object IDs in each respective file.

For example, the output table will have a field called INPUT_FID.  This Joins to the OBJECTID in the feature class used as the Input Features when running the Generate Near Table tool.

The output table will also have a field called NEAR_FID.  This Joins to the OBJECTID in the feature class used as the Near Features when running the tool.

Generate Near Table—Help | ArcGIS Desktop 

(note - the header in this topic says ArcGIS Pro but the information is the same for ArcGIS Desktop)

Chris Donohue, GISP

0 Kudos
ChrisDonohue__GISP
MVP Alum

What Joshua Bixby proposed is the probably the easiest way to do this. 

As an alternative, if you are comfortable with Modelbuilder, here's a model that would probably work after some modification to the specifics of your data.  As a preliminary step, one would manually join the offices to your projects layer before running the model.  Then the model selects each office from the office feature class and the projects with the same office and just runs a Pointdistance on each.  Finally, the Pointdistance values are joined to each offices file, resulting in a feature class for each office with only the projects for that office and their distances.

This model worked with the test data I threw together.  Note that you may also be able to skip the Copy Features function in the model.  I added it as a way to check the intermediate data.

Chris Donohue, GISP

0 Kudos
JoseBarrios2
New Contributor

Hello Chris,

Thanks a lot for your help..I would give it a try.! I am on desktop 10.4 butt I forgot to ask if Pro may have this capability.?

Thanks,

JB

0 Kudos
DanPatterson_Retired
MVP Emeritus

The toolboxes are essentially identical... Generate Near Table in Pro

0 Kudos
AbdullahAnter
Occasional Contributor III

Also you can try this model.

follow instructions as in the picture:

after model finished , run append tool to make all result tables in one table .

0 Kudos
JoseBarrios2
New Contributor

I have two data sets (.shp) and a common key field ID ( with one - to many). Yes, both files are on the same projection (USA_Contiguous_Equidistant_Conic) and  YES they cover very large distance (more than 100 miles)

0 Kudos