Skip to content
Prev 7256 / 29559 Next

grids, points, and RandomForest

Here's a general recipy:

1. import all the layers in R, using readGDAL in package rgdal, in case 
they're geotiffs e.g.

library(rgdal)
b1 = readGDAL("b1.tif")
b2 = readGDAL("b2.tif")
...
etc. and your response variable
y = readOGR("y.tif")

2. make sure they are all in a single R object, e.g.

b1$band2 = b2[[1]]
b1$band3 = b3[[1]]
...
etc.
b1$y = y[[1]]

3. Use RF predict:

library(randomForest)
b1$out = predict(randomForest(y~band1+band2+band3,as.data.frame(b1)))
spplot(b1, "out")

or write b1["out"] back as a geotiff using writeGDAL, and import in arcGIS.

This was of course all without trying, so that's now up to you.

Best wishes,
--
Edzer
LeRoy Elliott wrote: