Sort in memory feature layer arcpy

2204
9
05-11-2016 01:20 PM
ArjunDongre
Occasional Contributor

I am aware that I cannot use the sql_clause parameter on arcpy in-memory layers, the dataset must exist in a database. However, the program I have written must then write out a file every single time I run a network analyst problem (and subsequently delete it). I am working with tens of thousands or records, and half a dozen or so route solves per record. I need to reduce my iteration processing times as much as possible, and not having to write out a file every time would save a ton of time.

I am specifically trying to sort the junctions output from the copy traversed features method on a closest facility later, stored in-memory of course.

Any work-around would be much appreciated. Thanks!

0 Kudos
9 Replies
ArjunDongre
Occasional Contributor

I have tried list comprehension, but the output didn't make sense. I need to revisit tomorrow, however.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

I believe I understand your overall challenge, but I can't provide any specific feedback without knowing more about your data.  Can you provide some examples or attach an extract of your data and explain what you are trying to do with the data?

0 Kudos
ArjunDongre
Occasional Contributor

I just realized something, so let me test before I send you a reply.

Thanks for your response!

0 Kudos
ArjunDongre
Occasional Contributor

Hi Josh,

Thanks for the quick response. I just realized something that I need to test, and I broke my program, so Im debugging at the moment. I’ll update you if I figure out the solution!

Thanks!

Arjun

0 Kudos
ArjunDongre
Occasional Contributor

Okay, I was able to switch around my facilities/incidents and “travel_to/from” parameters to sort out in the order I needed and therefore didn’t have to worry about sorting again later.

Thanks for your help though!

0 Kudos
WesMiller
Regular Contributor III

You could use Sort—Help | ArcGIS for Desktop  to sort your data. You may also be interested in Generate Near Table—Help | ArcGIS for Desktop

ArjunDongre
Occasional Contributor

Thanks for the help. I looked into Sort, but it write’s out another table to disc which I then have to read. I am trying to avoid writing to disc, same with generate near table.

I have also looked into a list comprehension as well, which I was able to get partly. I need to look into a bit more.

0 Kudos
WesMiller
Regular Contributor III

Both of the tools can be used in_memory

ArjunDongre
Occasional Contributor

That may work then. I just want to try and limit the number of extra steps as well. I’ll look into it. Thanks!

0 Kudos