Calculate travel distance between each point

1069
13
05-23-2022 02:53 PM
tutu
by
New Contributor

Hi,

I have two point layers, origination, and the destination. I want to calculate the travel distance and time between each origin and destination point. For example, here is the dataset:

Origin             Destination 

1                            X

2                            Y

3

And eventually, there will be 6 routes, 1X, 2X, 3X, 1Y, 2Y and 3Y. How should I do that in the network analysis or in ArcGIS?

0 Kudos
13 Replies
MelindaMorang
Esri Regular Contributor

The documentation on the GitHub site should explain all the tool inputs and their requirements.

It sounds like your input data is not in an ArcGIS feature class or table or whatever but rather some sort of dataframe (pandas?).  For the tool to accept that as input, you have to first convert it to a feature class.  You could try using XY Table To Point or manually constructing a feature class with an Insert Cursor.  I can't really advise without knowing what type of data frame you're using or what's in it.

0 Kudos
CNDC_OPAOperational_Performanc
New Contributor
I understand I am using:

(input_destinations_csv) is a pandas dataframe

sdf_destinations = pd.DataFrame.spatial.from_xy(input_destinations_csv, 'Longitude', 'Latitude')
# Convert to Feature Class
sdf_destinations.spatial.to_featureclass(location=destinations_fc, overwrite=True)

I do the same for the origins. And then am running:
arcpy.LargeNetworkAnalysisTools.SolveLargeODCostMatrix(
Origins = sdf_origins,
Destinations = sdf_destinations,
Network_Data_Source = network_dataset,
Travel_Mode = "Driving Time",
Time_Units = "Minutes",
Distance_Units = "Miles",
Max_Inputs_Per_Chunk = 1000,
Max_Processes = 4,
Output_Updated_Origins = current_dir + '\Output_Origins',
Output_Updated_Destinations = current_dir + '\Output_Destinations',
Output_Format = 'Feature class',
Output_OD_Lines_Feature_Class = current_dir + '\Ouput_OD_Lines',
Cutoff = 240
)

But am getting an error that I am not currently able to interpret.

ExecuteError: ERROR 000582: Error occurred during execution.
0 Kudos
MelindaMorang
Esri Regular Contributor

Yeah, I'm not sure what that error code means.  The tool's code is not raising that error, so it means the error is probably occurring before the tool's code even starts running.

Where are you running this code?  From a standalone Python script?  From a notebook within Pro?  From a notebook somewhere else?

Did you import the toolbox using arcpy.ImportToolbox() or arcpy.AddToolbox()?

0 Kudos