Select to view content in your preferred language

How to accelerate a process using Model Builder or Python

3025
5
08-25-2014 10:46 AM
EfstathiosMargaritis
Deactivated User

Hello Geonet community. Please send me your thoughts to the question below.

I have to calculate a single indicator (.e.g Morans I) for multiple tiles within a study area. What I did so far was to insert all tiles (30) in Model Builder and then copy and paste the "Morans I" tool 30 times, one for each tile.The only thing that needs to be done is to change the name of the output file in each case.

Since the whole process is time consuming especially if I have 60 or 90 tiles, please let me know if there is a way to accelerate this process either by creating the same model in Python or in Model Builder.

Thanks

0 Kudos
5 Replies
XanderBakker
Esri Esteemed Contributor

It sounds to me that your are not so much trying to do this analysis in a parallel process, but would like to know if you can create a model or script more easily to do the analysis. That is indeed possible.

In modelbuilder you can use iterations. Read the following topic to start: A quick tour of using iterators

It is also possible to use python to perform this task. Personally I feel more comfortable with python to perform repetitive tasks. You would probably one of the arcpy.List* tools to get a list of the input data you want to process. Next you loop through all the items in the list and for each input item you define the output name and execute the Morans I tool.

If you look at the Help page on Spatial Autocorrelation (Global Moran's I) (Spatial Statistics) and scroll down you'll find examples of executing the tool (including OLS and SWM).

You can also perform the process manually for one input and go to the Results window and right click on the excuted process which will reveal the option to copy the python snippet. This can also be used to start.

Kind regards, Xander

EfstathiosMargaritis
Deactivated User

Dear Xander,

"Iterators" is the magic keyword in my question. Since I have never used them before, I now have to check how to perform this task first in model builder and then in python.

Thanks for the answer,

Stathis

0 Kudos
EfstathiosMargaritis
Deactivated User

I tested all the iterations and unfortunately none of them can produce multiple outputs. Only the iteration of "multivariate" can accept multiple inputs, but it has only one output. If somebody can give me a feedback for this it would be very useful, as I have spent so many hours looking for the solution.

Thanks

0 Kudos
curtvprice
MVP Esteemed Contributor

Multiple outputs can be created by an iterator at each iteration by uniquely naming the outputs using model variables in the string. In this case instead of model elements I'm using the built-in variables "workspace" (environment workspace) and "n" (0...n count set at each iteration step).

%workspace%\output%n%

This is covered in the help on iterators. (Note iterators do not work in Python, they are just a Model Builder thing.)

There is a bug in 10.2 that makes this not work for some iterators when run as a tool that is fixed in 10.3. This does work fine when the model is run from edit mode though.

Bug in Modelbuilder iterators when run as tool

0 Kudos
EfstathiosMargaritis
Deactivated User

Finally what I needed was not related to iterators but the "list of values" ArcGIS Help (10.2, 10.2.1, and 10.2.2) option in the model builder builder. Iterators are useful only in case of multiple inputs.

The list of values allows multiple inputs and produces the respective number of outputs providing also the output name.

It is very useful!