# Using Regression Trees in ArcGIS

I have a follow up question to Statistical analyses for survey against raster?

I have a very similar problem as the initial poster David. I am creating a multivariate model from raster data in order to predict a response variable. In my case I am using soil and climatic data to predict crop yields.

I independently came to a very similar conclusion as the answer posted by Aaron, to use zonal stats, export to R, and create a Random Forest model. However, I am now stuck because I want to create a raster in ArcGIS of my predicted yields based on the input rasters but I can't figure out how to translate the output from R to Arc.

In R I used this code:

``````library(randomForest)
fit <- randomForest(Yield ~ .,   data=data)
print(fit) # view results
importance(fit) # importance of each predictor
plot(predict(fit))
``````

The output a plot that reasonably predicts yield.

What I want to do is take the Random Forest model and use rasters of my predictor variables (e.g. slope) from a new location, and predict the yields for the new location. I understand how this works with simple linear regression but I can't wrap my head around how to do this with Random Forests. What equation does RF use to make the prediction plot? How can I get that equation and its coefficients from R to make a new map in Arc?

• Why don't you just compute the predictions in `R` and write them to a raster export file that ArcGIS can read? Commented Jul 30, 2013 at 18:14
• Or even take your entire workflow into R... Commented Jul 30, 2013 at 20:43
• I looked into using raster processing in R for a different issue but I am doing it over a large area and R's rasters were too slow or crashed, so I don't think I can take the whole workflow into R. But if you have any suggestions on computing rasters in R I will look into it more. I also don't really understand how to random forests make the predictions so I don't get how to feed it data from new rasters so that I export those predictions to Arc... Commented Jul 31, 2013 at 19:38