[R-sig-Geo] raster algebra in R

Robert J. Hijmans r.hijmans at gmail.com
Sat Aug 1 02:25:39 CEST 2009


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:
> Oops.
>
> Yes! Sorry, I forgot to mention this!
> Robert, cold you just write a example out output a .asc file?
> Just to keep this thread complete.
>
> bests
>
> milton
>
> On Fri, Jul 31, 2009 at 5:20 PM, Robert J. Hijmans <r.hijmans at gmail.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:
>> >
>> > 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
>> >
>> > _______________________________________________
>> > R-sig-Geo mailing list
>> > R-sig-Geo at stat.math.ethz.ch
>> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>> >
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>



More information about the R-sig-Geo mailing list