[R-sig-Geo] grids, points, and RandomForest

Edzer Pebesma e.pebesma at gmail.com
Thu Dec 24 16:31:39 CET 2009


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:
> I'm new to using geo info in R, though I'm familiar with Arc & R.
>
> I have numerous ESRI grid files with image band and biophysical info that I'd like to use with RandomForest to do predictive habitat modeling with species occurrence points. I've tried looking on the web, but haven't found anything helpful.
>
> Can anyone point me to a resource that can step me through this process? I need to stack multiple grids and use the info from point locations with RandomForest. The grid files all have the same cell size, same projection, and the point locations are also in the same projection. So, I think the data is ready to go.
>
> Lee Elliott
> Missouri Resource Assessment Partnership
> University of Missouri
> Columbia, MO 
>  		 	   		  
> _________________________________________________________________
>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>   

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster 
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251 
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de 
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list