Model builder: I need to run a tool without creating unecessary clipped outputs

2762
4
02-23-2016 03:35 PM
RuthLowry1
New Contributor

I'm completely new to model builder, but as I've about 90 rasters to run through several different processes I figured I'd construct a simple clip tool which then applies a function to the clipped data to convert it from Kelvin to Celcius values. My model looks as follows:

clip-convert model.PNG

The tool did not successfully run in ArcMap (it would fail while running the clip) until I had altered the model for a couple of hours. The tool now works more or less as desired; it clips the original data, and generates a second output with the new values. However, the tool would only work when I made the first output ("clipped raster") a paramater. Therefore the tool is not ideal as 1. having to choose an output location for the clip each time is less efficient and 2. as the clip itself is not needed superfluous data will be generated. I am not sure I completely understand how scratch data or scratch workspaces work, but is there any way that I would be able to set the "clipped raster" output as intermediate data and still have a functioning tool?

Other notes: on a previous attempt at constructing the model, I got the clip to run successfully, but it was always the raster calculator operation that failed; an error 000539 was always returned. Any idea on why this might be so? The function I entered into the raster calculator was ("%Clipped raster%" * 0.02) -273, 0.02 being a scaling factor and of course the 273 to convert from Kelvin to Celsius. However, I do not believe that syntax was the issue as I ran the function in the raster calculator in the system toolbox and there were no issues.

0 Kudos
4 Replies
DanPatterson_Retired
MVP Emeritus

If your raster bounds were rectangular, you could simplify everything by simply setting the analysis extent and doing the math, skipping the clip altogether.  Alternately, set your environments to overwriteoutputs and reuse the clipped name.. go one step further and specify in_memory as the destination location.

TiffanySelvidge1
Occasional Contributor III

I second the overwriteoutputs options and suggest switching to python.

When using Modelbuilder, I discovered the model ran better from python than using the modelbuilder itself in ArcCatalog. The reason is that Modelbuilder kept getting confused about the datasource for my parameter. Once in python, it no longer needed to be defined as a parameter and I was able to specify the exact pathway and connection for the file and my code now runs smoothly. The same concept could be happening in your model. Try exporting it as python script and defining the pathway. Remember to add in the script for overwrite:

arcpy.env.overwriteOutput = True

RuthLowry1
New Contributor

Sorry for the delayed response.

@Dan: I had defined the scratch workspace as %scratchworkspace% but it
wasn't until I realized that I had to update that field in environments as well
as model properties and I took your advice to go with in_memory as the scratch
workspace as well as choosing to override outputs that I got the output I was
looking for. Thank you.

Sorry Tiffany, but I have no knowledge of coding, something which I think I
will have to pick up at some point.

So now that I have my basic modelling running I realized I could add one
more process to it. The converted values need to be converted to point data so
I added the From Raster to Point conversion tool to the end of the model,
making the original final output intermediate data using the same solution as
above. I cannot tell if the tool will successfully run because ModelBuilder is adamant on not letting me define the destination location of the final output (again, the tool will need to be run
with many inputs and so the output must be defined each time). Every time I try
to clear the output field it returns to I:\MSc GIS & Remote
Sensing\GY638\GY638 Project\Land cover data\RasterT_results1.shp (as seen
below). Any idea on why this might be?

clip-convert-point model.PNG

0 Kudos
DanPatterson_Retired
MVP Emeritus

The output path is breaking just about every rule of acceptable path names when working with rasters... and in general practice... no spaces, no weird characters (except underscore), short (<128ish I think characters), drives should be real (or in memory... usb drives have caused me no end of problems when I teach in class)

So perhaps it is the input locations as well.  I would suggest a reconsolidation and move stuff to simpler folders or into a geodatabase.  Once verified there, then you have removed one of the common issues with things failing... file and folder structure.