2

I would like to know if there is any way to use Python in ArcGIS Pro in a similar way to SPSS syntax. I mean if there is a way that while I click in ArcGIS the code starts to auto-generate and then I can copy/edit it the way I want. I ask this because I know that with R or Python someone can automate processes but I don't know anything about those languages, and maybe this way would be easy to get familiar with the code (like in SPSS).

2
  • 3
    Welcome to to GIS SE. As a new user, please take the Tour, which emphasizes the importance of asking One question per Question in out Focused question/Best answer model. A question about "R or Python in ArcGIS or QGIS" is at least four questions. Boolean questions, especially those in the form of "is there any way" are generally too open-ended to result in more than a (unhelpful) "Yes," though this seems a candidate for an (equally unhelpful) "No." It seems as if you're really asking if you can avoid learning about GIS processes while using GIS software, and that answer is also likely "No."
    – Vince
    Commented Aug 22, 2020 at 19:05
  • 1
    The closest I can think of would be to build a model in model builder and then export the python code.
    – Aaron
    Commented Aug 22, 2020 at 19:05

4 Answers 4

5

The short answer is no. BUT enter image description here

You can send a Python command that you have just run to the Python window as shown below

0
2

There is an ArcGIS Idea named A Macro Recorder for Python for something like this in the ArcMap application of ArcGIS Desktop:

Like the "macro recorder" of Excel, all your manual actions in ArcMap data view are instantly translated in Python commands.

You could post a new ArcGIS Idea there for a Macro Recorder that writes ArcPy code from ArcGIS Pro.

1

Answer 2 As Aaron has mentioned - have a play with model builder: https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/modelbuilder/modelbuilder-quick-tour.htm

and then export to Python: https://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/modelbuilder/exporting-a-model-to-python.htm

It's also a good way to get started.

3
  • Thanks, your response and Aaron's were pretty good. In any case, the method have limitations because, for example, it could not be used when creating maps, right? Commented Sep 4, 2020 at 11:55
  • I'm not sure what you mean as I'm not familiar with SPSS. If you are meaning something that will record your actions and then produce code (like say, recording an excel macro), then yes - you are correct. Both are ways to get started faster than just trying to write code from scratch.
    – LeasMaps
    Commented Sep 5, 2020 at 5:50
  • 1
    Jose: or example, it could not be used when creating maps, right? No - your history will be recorded when you are creating maps.
    – LeasMaps
    Commented Sep 5, 2020 at 5:58
1

It's not quite as direct, but using Pro's Tasks, you can have the application "record" what you're doing and clicking, and it will add all of the tools, toolbar items, and map views that you click to items in a task.

You can see the specifics in Esri's documentation.

This doesn't necessarily get you the Python, but can identify the specific items you click on by name, which you can then track down in Esri's Python docs. Useful for when the sequence you're recording isn't solely in the GP tool.

1
  • Can you edit or adapt things? Ie, use the same flow with a different input file? Can the flow be converted to ModelBuilder.
    – Mox
    Commented Feb 9 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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