Skip to content

raster algebra in R

7 messages · Jason Robinson, stephen sefick, milton ruser +1 more

#
I need to do some raster algebra on some large rasters.  right now they are ascii files.  I'm a complete R novice.  Can anyone point me towards a good source for figuring out how to get my data into R and how to do very simple raster manipulations?  no advice is too simple for this guy.  appreciate any help that is out there

Jason Robinson
#
Have a look at the spatial task view.  I use GRASS GIS for raster
processing, and maybe this would be helpful-http://grass.osgeo.org/.
hth,

Stephen Sefick
On Fri, Jul 31, 2009 at 1:21 PM, Jason Robinson<litobrancha at yahoo.com> wrote:

  
    
#
You can try the raster package, available from R-forge:

install.packages("raster", repos="http://R-Forge.R-project.org")

It has very simple raster algebra

r1 <- raster('myfile1.asc')
r2 <- raster('myfile2.asc')
r3 <- r1 + sqrt(r2) + 1

etc.

Robert
On Fri, Jul 31, 2009 at 11:21 AM, Jason Robinson<litobrancha at yahoo.com> wrote:
#
Here is a sample script where the results are saved to an ascii file.

r1 <- raster('myfile1.asc')
r2 <- raster('myfile2.asc')
r3 <- r1 + sqrt(r2) + 1
filename(r3) <- 'output.asc'
r3 <- writeRaster(r3, filetype='ascii')
On Fri, Jul 31, 2009 at 2:24 PM, milton ruser<milton.ruser at gmail.com> wrote: