Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am looking for some tips about inserting a script in the ModelBuilder...

I am actually building a model in the ArcGIS ModelBuilder. At one point I would like to insert a script that crosses information from two layers at one point of the model with a output layer, that will be used further along.

In ArcMap, I added the script with a right-click in My Toolbox > Add Script...

After loading my script, I applied the following parameters:

  • Two inputs, referring my layers that I use in the script (raster layer type)
  • One output, for the result (raster layer type)

I then go to my model and drag my script into it. I connect my two layers as inputs with the arrow and specify the output file name. All seems ok as the boxes appear with the correct colors.

I have to specify that I am working with a variable folder %folder% so I added that in my script.

When I validate my model it goes all blank, because it cannot find the input layers, as they are created in the model.

Can anybody help me please?

PS: Here is my script:

# ---------------------------------------------------------------------------
# calculator.py
# Created on: 2012-11-15 16:59:11.00000
#   (generated by ArcGIS/ModelBuilder)
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Check out any necessary licenses
arcpy.CheckOutExtension("spatial")


# Local variables:
raster = "%Dossier%\Erosion.gdb\raster"

# Process: Calculatrice raster
arcpy.gp.RasterCalculator_sa("Con((\"%Surf_Drainee%\" > 12) & (\"%Surf_Drainee%\" <= 80) & (\"%Pente_Rclass%\" <= 24), \"%Pente_Rclass%\" + 1, Con((\"%Surf_Drainee%\" > 80) & (\"%Pente_Rclass%\" < 24), \"%Pente_Rclass%\" + 2, Con((\"%Surf_Drainee%\" > 80) & (\"%Pente_Rclass%\" == 24), \"%Pente_Rclass%\" + 1, \"%Pente_Rclass%\")))", raster)
share|improve this question

closed as unclear what you're asking by PolyGeo, Simbamangu, Devdatta Tengshe, whuber Jan 10 at 15:19

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

3  
Take a look at this question –  om_henners Nov 16 '12 at 22:21
    
If @om_henners comment (which links to excellent advice) does not resolve your issue please try to post a screen shot of your model and the settings of the Python script tool that uses your Calculator.py script. That script looks like it needs some arcpy.GetParameterAsText (or GetParameter) lines to ingest its parameters. –  PolyGeo May 21 '13 at 11:31
    
Hi Maxim L, have you got any answer? –  alextc Jul 26 '13 at 6:48
    
Hi, we didn't manage to solve the issue and ended up by running the Model Builder. It was an assignment for university and even having asked the supervisor for help, we never got any feedback for it! –  Maxim L Jul 28 '13 at 16:10
add comment