Hi all,
I wrote a python geoprocessing tool.
If I run it in Arcgis pro it takes about 11 minutes, but if I run it outside Arcgis pro it takes hours?
I don't know why!
The tool loops over records in a csv file (about 6700 rows)
For each row performs a spatial selection (arcpy.management.SelectLayerByLocation) creating a layer.
After that, it performs some selections and calculations with the selected features and write results in a file geodb table (see the attachment).
If I run the tool in Arcgis pro it takes about 1 seconds to process 10 record in the csv file.
When I run outside Arcgis pro, it starts with 1 sec for 10 recs, but after few loops it takes 1 second for 1 or 2 records.
Does anybody have any ideas or suggestions?
Thanks in advance.
Solved! Go to Solution.
Thanks to @JohnSobetzer @JoeBorgione and @AmyRoust for the suggestions!
I changed my script: now I'm using GenerateNearTable and Intersect tools instead of SelectLayerByLocation and cursors.
Now it takes about 5 seconds instead of 11 minutes!
You might check this out even if it refers to 10.3. in particular the use of layers over data on a drive. https://desktop.arcgis.com/en/arcmap/10.3/analyze/sharing-workflows/performance-tips-for-geoprocessi...
Perhaps apply arcpy.MakeFeatureLayer() on your feature classes first and reference those feature layers (in memory) to make your spatial selections. Just a guess...
Kind of a long shot, but is your data on a network drive? That's usually what slows down my scripts (though the lag time is worse inside Pro than outside). If your data is not on your local machine, it could be a latency issue where the computer is having to work harder to access the data and write the results.
Thanks to @JohnSobetzer @JoeBorgione and @AmyRoust for the suggestions!
I changed my script: now I'm using GenerateNearTable and Intersect tools instead of SelectLayerByLocation and cursors.
Now it takes about 5 seconds instead of 11 minutes!