OD Cost Matrix - Map ID fields for Origins and Destinations

329
2
Jump to solution
03-16-2023 07:04 AM
ScottFedak2085
Occasional Contributor

I may be missing something, but I haven't seen an area where you can map a chosen ID field when importing Origins and Destinations. The Name property is the only kind of field where this mapping is possible, but then the Origin and Destination data is concatenated together in one field. 

It would be preferred to be able to map an ID field that is concatenated together like the Name property, but also split up into their own OriginID and DestinationID fields...almost like building a junction table right into the output to take advantage of in post analysis operations. It's not too hard to map ID fields to the Name property and do some string manipulation to split out the information, but seems kind of surprising this isn't an option. It seems like a typical operation after conducting an OD Cost Matrix would be to join it back to the original data in some way to populate attributes or conduct additional analysis.

0 Kudos
1 Solution

Accepted Solutions
MelindaMorang
Esri Regular Contributor

If you're using an OD Cost Matrix layer, you can use the Add Field To Analysis Layer tool to add fields to the Origins and Destinations sublayers suitable for storying your ID.  When you run Add Locations to load your inputs, you can map your ID field to these new fields in the sublayers.  When you solve, you can do a join between the Lines sublayer and Origins or Destinations.  The OriginID field in Lines corresponds to the ObjectID field in Origins, and the DestinationID field corresponds to the ObjectID field in Destinations.  This should allow you to transfer the fields in whatever way you need.

If you're using the arcpy.nax solver objects, the procedure is similar but depends on how you're loading inputs.  This is documented here: https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/setting-analysis-inputs.htm#ESRI_SECT... The schemas for the output classes and the relationships between them are described here: https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/origindestinationcostmatrix-output-da... 

View solution in original post

0 Kudos
2 Replies
MelindaMorang
Esri Regular Contributor

If you're using an OD Cost Matrix layer, you can use the Add Field To Analysis Layer tool to add fields to the Origins and Destinations sublayers suitable for storying your ID.  When you run Add Locations to load your inputs, you can map your ID field to these new fields in the sublayers.  When you solve, you can do a join between the Lines sublayer and Origins or Destinations.  The OriginID field in Lines corresponds to the ObjectID field in Origins, and the DestinationID field corresponds to the ObjectID field in Destinations.  This should allow you to transfer the fields in whatever way you need.

If you're using the arcpy.nax solver objects, the procedure is similar but depends on how you're loading inputs.  This is documented here: https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/setting-analysis-inputs.htm#ESRI_SECT... The schemas for the output classes and the relationships between them are described here: https://pro.arcgis.com/en/pro-app/latest/arcpy/network-analyst/origindestinationcostmatrix-output-da... 

0 Kudos
ScottFedak2085
Occasional Contributor

Would you look at that, didn't know that GP Tool existed. Thanks!

0 Kudos