1

I've recently began trying out basic geoprocessing tools by using arcpy (clipping layers, buffering, etc).

However, this seems slower than using the ArcMap GUI.

Are there any advantages to using ArcPy for simple tasks that can otherwise be done directly through the GUI?

2

As you have noted the geoprocessing tools are slower than their ArcMap GUI equivalents, if the latter exist.

My superficial understanding is that this is because ArcMap already has all the functions needed by the ArcMap tool loaded in memory, whereas geoprocessing tools load that functionality before starting to run.

The compelling use case for geoprocessing tools comes when you want to string automation operations together using ArcPy, ModelBuilder, etc.

If you are already in ArcMap, and if there is a tool available in its GUI that does what you want, then I would recommend using that.

  • Thank you for your answer. When I said slower I was more referring to the act of typing in code, reviewing that the code will run correctly and then actually running it, vs clicking a few buttons in the GUI. – socks Nov 24 '15 at 3:40
  • I suppose I will continue to use the GUI for simple tasks but I will look into the model builder. Thanks. – socks Nov 24 '15 at 3:41
  • Arcpy is a wrapper around ArcObjects, so while it provides access to some AO functionality, the extra level of redirection makes it slower. Also note the some. Arcpy is not a complete replacement for AO and there are some tasks that can't be performed with python alone. – jon_two Nov 24 '15 at 9:15
  • Arcpy is also useful when you are trying to do things that are not readily available in the GUI but may be in other python libraries, e.g. advanced statistical analysis, regular expression parsing, or access to data types outside ArcMap's normal types. – blord-castillo Nov 24 '15 at 14:40
2

To some folks used to writing code, typing it out is actually sometimes faster (I actually use a running Python IDLE session alongside the ArcMap GUI to do things sometimes, this being faster than the autocomplete in the ArcMap Python window).

Scripting and automation is an important advantage of using arcpy, as mentioned by @PolyGeo.

Another is the ability to use other Python libraries along with the ArcGIS tools (e.g., scipy, numpy or matplotlib for math and stats, QGIS and other GIS, system shell commands, writing log files, manipulating non-Esri format files like CSVs...).

2

I have noted that the ESRI helpfile is increasing limited for GUI information, and more likely to turn up a python option - quite annoying for teaching students - but one reason to learn a bit of python.

With code you have a very neat record of exactly what commands were run in what order and with what parameter settings. Useful for both tracing errors and quickly changing one setting for multiple steps.

Finally, as stated by others, it is useful for stringing operations together, or calling functions from other software.

For one off tasks, GUI is usually simpler.

  • The record kept of things with code is a great bonus, though the Results window in ArcMap (new since 10.0, I think) addresses keeping a detailed processing record via the GUI too. – Paulo Raposo Nov 24 '15 at 21:03
2

I think it all differs on how familiar you are with what you're doing. If you can quickly navigate the toolboxes or search for your specific GUI tool quicker than you can write out code in the interactive window, then that is the route to take. If the inverse is true, then stick to coding in the interactive window.

I always suggest to co-workers to use the interactive window when time isn't pressing. This is a good way to get more comfortable and familiar with both the python syntax and the arcpy modules. However, it isn't quicker initially as everyone was trained to search for the tool or navigate the toolboxes.

I always have the interactive window showing and find it very quick to just drop a little code in there. My toolboxes and search panels are closed so going that route takes more time. Just one off tools is a matter of preference really.

As @PolyGeo said, it is best when chaining things together. I use a loop trick to chain together tools and process it all at once.

For instance:

layers = ["layer1"]
for layer in layers:
  arcpy.AddField_management(layer, "TEXT", "SomeField")
  arcpy.CalculateField_management(layer, "SomeField", "!Field2!", "PYTHON_9.3")
  arcpy.DeleteField_management(layer, "Field2")

Those are simplistic examples, but I find it easier than individually opening each tool and running it. Plus, you get the added benefits of python when doing it in code. Whether it is string manipulation or pulling in other modules (e.g. Math module or SciPy, etc), you get more options.

But for simple tasks, stick with what's faster for you unless you are wanting to learn or do more complex tasks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.