I run the OLS (Ordinary Least Squares) tool in my model and output a coefficient table. Now I need to use the slope and intercept values in the coefficient table in a Raster Calculator. I've tried using the different iterators (Row Selection, Field Values) but they only output one value at a time.
Does anyone know how to get "SearchCursor"-like functionality in ModelBuilder?
Here's a picture of the model:
and a picture of "coef_table":
How do I get the two values in the Coef column as separate values that I can use in the Raster Calculator?
Answer
If you are using ModelBuilder and want to create a list of values then use the Field Values iterator and send the output to a Collect Values tool. Expose the output values as a parameter, then embed this sub-model into the master model.
Having created your list of values (in your example you are returning just two values) you can use the Calculate Values tool to extract them into their own variables which you can then use with inline-substitution in your raster calculations.
The Calculate values tool uses the following python code, note I am returning an integer value in my example, you may want to use float? Variable v1 is index 0 and v2 is index 1. It are these v1 and v2 that you use in your raster calculation.
No comments:
Post a Comment