Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alter outputting OID to other unique ID from input origins/destinations #16

Closed
Erin-1919 opened this issue Feb 28, 2022 · 3 comments
Closed

Comments

@Erin-1919
Copy link

Is there a way I can alter the output OriginOID and DestinationOID so that they correspond to another unique ID field (instead of ObjectID) of the input origin/destination feature classes?

@mmorang
Copy link
Collaborator

mmorang commented Feb 28, 2022

Hmm, I think I know what you're asking for: Your original Origins and Destinations files have some field for an ID or unique code or whatever. You want to transfer this value through to the final output. Is that right?

It's not possible to alter the OriginOID and DestinationOID fields (well, I guess you could in post-processing if you wanted to). But what you can do is pass through the original field values in addition to OriginOID and DestinationOID. You'll need to include your fields in the inputs when calling the load() method, and then once the OD Cost Matrix is solved, you'll need to join the output Origins and Destinations to the Lines to transfer over the values of that field.

This section in the arcpy.nax documentation explains how to include custom fields when loading inputs. You'll want to apply this information here: https://github.com/Esri/large-network-analysis-tools/blob/master/parallel_odcm.py#L312-L356. There's already some fields getting added and mapped, so it should be a straightforward addition to what's already happening.

For doing the join on the results, the code is actually already doing a similar join in the case where the network data source is a service. It's transferring the ObjectIDs, but the same idea would apply to any other field. You can see that here: https://github.com/Esri/large-network-analysis-tools/blob/master/parallel_odcm.py#L493-L524. The key thing to understand is that the fields in the input Origins and Destinations get transferred to the output Origins and Destinations. The OriginOID field in the output Lines refers to the ObjectID field in the output Origins, and the DestinationOID field in Lines refers to the ObjectID field in the output Destinations. So you'll want to use these fields to make joins and transfer any other fields you want over to Lines.

(I'm not sure what kind of output you want, and the steps may differ a little for feature class, CSV, or Arrow.)

@mmorang
Copy link
Collaborator

mmorang commented Mar 9, 2022

Did this satisfactorily answer your question? If so, please close the issue. (But it's okay if you need some time to think about it and play with it.)

@Erin-1919
Copy link
Author

Thank you; it helps a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants