I am trying to calculate the distance between some geographic features (point layer) and the capital of the country that they fall in. I have a shapefile of "features" and a shapefile of "world capitals". My current system is to generate a NearTable between the two layers and then use another program (Stata) to keep only the relevant distances (where the country of the feature and city are the same). However, my program takes a while to run when I do this because, due to the size of the countries I'm looking at, I need to calculate the distance between all points and the nearest 20 capital cities.
Is there a faster way to do this?
Here is a snippet of my code:
in_features = gpts near_features = world_capitals arcpy.GenerateNearTable_analysis(in_features, near_features, near_world_capitals_tbl, \ closest="ALL", closest_count="20", method="GEODESIC")
I am working in ArcPy, but answer in ArcMap are also helpful.