3

I am running a model which I created with ModelBuilder at 10.3. The model is supposed to make a selection by attribute on a feature layer, and use that layer to clip a raster. The model is working fine when I run it, however if I try to use it in batch mode it gives unexpected results: I have many files with the same extent and content as the first line of the loop (of the batch).

The parameters of my models are:

  1. the input feature layer against which a selection is specified
  2. the input raster (.BIL)to be clipped with the selected feature
  3. the SQL expression for the selection (of the type "FIELD" = 'value')
  4. the output folder and filename (with .BIL extension)

Basically, in the batch window the feature and raster parameters are fixed, I am only changing the SQL expression to point a different 'value', so that the output raster is clipped on different areas each time, and the filename name of the output.

Below is my model:

enter image description here

  • Comparing your parameters with your image, are parameters 2 and 3 in the correct order (left-to-right)? – Midavalo Jan 28 '16 at 17:24
1

Reading the output message of the geoprocessing tool in batch, I realized the batch is not looping as I expected. It seems it loops at each tool in the model for each line in the batch, rather than performing the entire model once and then passing the next line and so on.

So, it was sufficient to append an "%n%" to the first output variable ("judete_100_L" to become "judete_100_L0", then "judete_100_L1" and so on), not to let the batch process overwriting the output of each loop with the one after keeping only the only one at the end.

http://help.arcgis.com/EN/ARCGISDESKTOP/10.0/HELP/index.html#//002w0000001w000000

To clarify this behaviour, I attach the output message of the model run in batch.

Executing: SelectAndClipRomania \PATH\TO\Population\ROMANIA_POPULATION_MAP.bil \PATH\TO\Vector\shp\judete_100.shp ""Judet" = 'ALBA'" \PATH\TO\output_folder\MBoutput_01.bil
Start Time: Fri Jan 29 09:36:10 2016
Executing (Make Feature Layer): MakeFeatureLayer \PATH\TO\Vector\shp\judete_100.shp judete_100_Layer0 # # "FID FID VISIBLE NONE;Shape Shape VISIBLE NONE;Judet Judet VISIBLE NONE;Siruta_har Siruta_har VISIBLE NONE;Corectat Corectat VISIBLE NONE;Shape_leng Shape_leng VISIBLE NONE;Shape_area Shape_area VISIBLE NONE"
Start Time: Fri Jan 29 09:36:11 2016
Executing (Make Feature Layer): MakeFeatureLayer \PATH\TO\Vector\shp\judete_100.shp judete_100_Layer1 # # "FID FID VISIBLE NONE;Shape Shape VISIBLE NONE;Judet Judet VISIBLE NONE;Siruta_har Siruta_har VISIBLE NONE;Corectat Corectat VISIBLE NONE;Shape_leng Shape_leng VISIBLE NONE;Shape_area Shape_area VISIBLE NONE"
Succeeded at Fri Jan 29 09:36:11 2016 (Elapsed Time: 0,22 seconds)
Executing (Select Layer By Attribute (2)): SelectLayerByAttribute judete_100_Layer0 NEW_SELECTION ""Judet" = 'ALBA'"
Start Time: Fri Jan 29 09:36:11 2016
Executing (Select Layer By Attribute (2)): SelectLayerByAttribute judete_100_Layer1 NEW_SELECTION ""Judet" = 'ARAD'"
Succeeded at Fri Jan 29 09:36:11 2016 (Elapsed Time: 0,03 seconds)
Executing (Clip): Clip \PATH\TO\ROMANIA_POPULATION_MAP.bil "-20586,2072725614 4830748,2852006 712578,171046345 5345773,0034133" \PATH\TO\output_folder\MBoutput_01.bil judete_100_Layer0 2147483647 NONE NO_MAINTAIN_EXTENT
Start Time: Fri Jan 29 09:36:11 2016
Executing (Clip): Clip \PATH\TO\ROMANIA_POPULATION_MAP.bil "-20586,2072725614 4830748,2852006 712578,171046345 5345773,0034133" \PATH\TO\output_folder\MBoutput_02.bil judete_100_Layer1 2147483647 NONE NO_MAINTAIN_EXTENT
Succeeded at Fri Jan 29 09:36:27 2016 (Elapsed Time: 15,73 seconds)
Executing (Select Layer By Attribute (3)): SelectLayerByAttribute judete_100_Layer0 CLEAR_SELECTION #
Start Time: Fri Jan 29 09:36:27 2016
Executing (Select Layer By Attribute (3)): SelectLayerByAttribute judete_100_Layer1 CLEAR_SELECTION #
Succeeded at Fri Jan 29 09:36:27 2016 (Elapsed Time: 0,02 seconds)
Succeeded at Fri Jan 29 09:36:27 2016 (Elapsed Time: 17,67 seconds)
  • please, can you add there the print screen of your working model? or where did you append the %n%? thank you – maycca Apr 7 '17 at 9:58
1

I haven't attempted to run any of my models in batch mode before, but it sounds like something is being held over from the first step.

ArcGIS likes to hold on to layers and selections made when tools are run. It is possible that either the feature layer created in step one, or one of the selections created (step two or four) may still be held in memory and not reset on the subsequent runs of the batch. Adding a delete feature layer (make sure it's the layer and not the feature class) or a Clear Selection might fix the problem.

UPDATE:
The above didn't work. I had the same result - It output the correct number, but they were all the exact same extent! I tried exporting to Arcpy and had the same result until I cleared the Rectangle extent coordinates, and set Clipping Geometry to True. I tried these in the model with no success however.

Below is the arcpy code I got to work:

import arcpy

# Parameters from tool
InputPolygon = arcpy.GetParameterAsText(0)
Expression = arcpy.GetParameterAsText(1)
MyImage = arcpy.GetParameterAsText(2)
ImgOut = arcpy.GetParameterAsText(3)

# Feature Layer
InputPolygon_Layer = "InputPolygon_Layer"
arcpy.MakeFeatureLayer_management(InputPolygon, InputPolygon_Layer, "", "", "")

# Select features to clip
arcpy.SelectLayerByAttribute_management(InputPolygon_Layer, "NEW_SELECTION", Expression)

# Clip Raster
arcpy.Clip_management(MyImage, "", ImgOut, InputPolygon_Layer, "256", "ClippingGeometry", "NO_MAINTAIN_EXTENT")

# Clear Selection
arcpy.SelectLayerByAttribute_management(InputPolygon_Layer, "CLEAR_SELECTION", "")

It doesn't exactly answer your question (and I'm interested to see what the actual solution to this problem is), but may help you work around your current situation.

  • This is an un-tested theory, I'll test when I get in the office in an hour and update if needed. – Midavalo Jan 28 '16 at 17:14
  • 1
    I am getting the same result as you - everything outputs the same extent. If I tell it to delete my Feature layer I get errors on subsequent batch steps that the Feature Layer doesn't exist (when it tries to delete). It appears to be using the same Feature Layer extent for every batch step (even if it has been deleted). I did manage to get it to work, by making the Feature Layer output name a Model Parameter, and giving it a different name for each batch step. – Midavalo Jan 28 '16 at 19:06
  • 1
    @Mildavalo Thanks. I need to avoid using Python as my co-workers don't know it. Anyway, I found the problem, if you are interested, please read the answer I gave. – umbe1987 Jan 29 '16 at 9:02

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.