2

I've created a rather large model containing a sub-model that calculates the volume of water basins(playas) in a relatively flat area of Texas. The volume is taken from one foot slices of each each basin up to the point of overflow. I would like to use it to batch-process several sets of the input parameters sequentially.

There are 3 input parameters that are as follows: the map extent(XMin YMin XMax YMax) which the user sets around the basin to be processed; the name of a geodatabase to create(String variable); and the name of the basin itself(String) which is referenced within the geoprocessing tasks from an existing feature class. The model works great but I can only run it once.

I would like to be able to use the input as follows:

  1. Move the map view to the extent for the basin and and fill the grid for extent by using the drop down and selecting the "same as display option".

  2. Enter the new name of the geodatabase to be created.

  3. Enter the name of the Playa(basin).

  4. Repeat for all playas that need to be run(Batch).

The problem I run into is that the model will not run sequentially when using it in the batch window. I'm aware that this is a known limitation of the model builder environment and have had many suggestions that what I'm trying to do is better handled by a Python script. So....

  • Is it possible to write a script that calls the model in which I could batch process from the script using an iterator or some other method to repeat it? If so, how?

  • I would be okay with entering my parameters into an Excel sheet that could be read by the script. Is this possible? If so, how? Or, is this even necessary?

  • Would I need to rewrite my model in script form for this to even be possible?

Me: I have a small knowledge of python scripting, but am well versed in model builder.

I have not done much geoprocessing in python. Mainly small scripts that calculate values and other pretty light tasks.

I've included a picture of the model so you can get an idea of what I'm dealing with. I know that it won't really be readable. I can provide more in depth examples if needed.

Model

  • I thought i should mention... I've read several tutorials and even have the Python - Scripting for ArcGIS Book (Zandbergen) but have had little luck getting the model to be called by the scripts I've tried. – GeoJohn Sep 9 '14 at 14:46
  • 1
    Have you converted the model to a python script and taken a look at the output? There is some clean up to get the python script to fun fluidly, but for the most part, all of the geoprocesses and variables come across. Here's a link on exporting the model to python: resources.arcgis.com/en/help/main/10.1/index.html#//… – evv_gis Sep 9 '14 at 14:52
  • 4
    arcpy.ImportToolbox, then calling the model arcpy.Model_Alias() will run the model inside of your toolbox. See this: gis.stackexchange.com/questions/87775/… I was at a similar point a few years ago with a very extensive model and I decided to convert the model to python. It was a job to say the least, I too had no experience with python. I have to say, it was the best decision I could have made. For these complex models, python can simplify much of it. Again, yes it's a job, but the benefits definitely are there. – evv_gis Sep 9 '14 at 15:22
  • 1
    I agree with @evv_gis a model this complex would be easier to run and maintain if converted to Python. If you have a useful and totally self contained model this could be called by importing the toolbox. – Hornbydd Sep 9 '14 at 15:32
  • 1
    I agree with @evv_gis that ImportToolbox should provide the "quick fix" but if you decide to learn ArcPy/Python then (which I recommend) then I advise against exporting your model to a Python script as a starting point. I think ArcPy/Python is easier to learn by manually performing each step once and using Copy As Python Snippet from the Geoprocessing | Results window to build your script. – PolyGeo Sep 9 '14 at 21:53

Your Answer

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

Browse other questions tagged or ask your own question.