Point-to-point distance (multipoint)

1635
3
04-02-2017 06:25 PM
JoãoFrancisco_Pugliese
New Contributor II

Hello dear ArcGIS programmers,

I have a dataset with points on the center of municipalities in south Brazil. I have also a set of coordinates that are approximate locations of Jesuit Missions. I need to find the closest distance a municipality is from a mission, aka the minimum distance. 

I tried using MultiPoint to create a set of points and then use distance from that to obtain the minimum distance. Using syntax example I found online I didn't had much luck but to end in tears.

import arcpy

# A list of features and coordinate pairs
feature_info = [[[-50.963, -25.596], [-51.367, -25.191], [-54.353, -25.464], [-53.243, -28.28]],
[[-52.074, -22.597], [-50.463, -24.942], [-51.9, -22.69], [-51.689, -25.679]],
[[-51.689, -25.679], [-50.737, -24.489], [-50.975, -23,716], [-54.965, -28.2]],
[[-54.296, -28.512], [-53.899, -28.611], [-53.677, -28.538],[-55.959, -28.783]],
[[-53.15, -28.015], [53.243, -28.28], [-55.171, -27.776], [54.793, 27.485], [54.621, 27.478]]]

# A list that will hold each of the Multipoint objects
features = []

for feature in feature_info:
# Create a Multipoint object based on the array of points
# Append to the list of Multipoint objects
arcpy.Multipoint(feature)

As you can see, I wasn't even including the distance function in this example. 

If anyone can help me with the distance calculation, I would surely appreciate. It's been a while since I started using ArcGIS for this only purpose and so far only managed to create a central point for every municipality.

0 Kudos
3 Replies
DanPatterson_Retired
MVP Emeritus

you don't need to create a multipoint.  Why don't you just do it all in arcmap rather than starting from coding.

If you have the longitude/latitude in tabular or spreadsheet format, you can bring that data into arcmap as an 'event layer', then save it as a featureclass or shapefile.  If your other data are in a similar form, then repeat.  Once the data are in that format you can use the Near tool or Generate Near Table tool is you have the appropriate licence.  If you don't have the appropriate license, then there are other ways to get the results which are far simpler than coding a solution yourself.

JoãoFrancisco_Pugliese
New Contributor II

Hello Dan, thank you very much, I had no idea it was that straightforward...

If I may ask for another piece of help, I'm having trouble generating the NearTable in kilometers. I have two layers - the center of the municipalities and the missions - and the results were on a unit that I think was decimal degrees - small numbers between 0 and 3.

Reading some threads online I have set both on the South America Albers Conic Area PCS. My points then moved to southern Uruguay, and I put them back to SIRGAS 2000 (their original GCS).

So how do I obtain my results in kilometers?

Thank you in advance

0 Kudos
DanPatterson_Retired
MVP Emeritus

You are working with data which are in decimal degrees, presumably, therefore, you need to pay attention to the fine details of the tool's options... see below

method
(Optional)

Determines whether to use a shortest path on a spheroid (geodesic) or a flat earth (planar). It is strongly suggested to use Geodesic method with data stored in a coordinate system which is not appropriate for distance measurements (for example, Web Mercator and any geographic coordinate system), or any dataset which spans a large geographic area.

  • PLANAR —Uses planar distances between the features. This is the default.
  • GEODESIC —Uses geodesic distances between features. This method takes into account the curvature of the spheroid and correctly deals with data near the dateline and poles.

which would have accounted for your values being returned in portions of a degree rather than meters.

Use the Geodesic calculation method, which should return meters.  And if you really need the distance in km.  Add a new field to the table ...

ie Dist_km (double) and divide the distance in meters column by 1000.