[R-sig-Geo] How to change raster cell value by coordinates?

Thiago Veloso thi_veloso at yahoo.com.br
Thu Feb 9 16:29:08 CET 2012


  Dear list,

  I wonder if there is a way to change the values of a raster grid using the coordinates as a condition. Please consider the raster below:

> library(raster)
> amz<-raster("/home/data/amz.img")
> amz
class       : RasterLayer
dimensions  : 47, 65, 3055  (nrow, ncol, ncell)
resolution  : 0.5, 0.5  (x, y)
extent      : -74, -41.5, -17.5, 6  (xmin, xmax, ymin, ymax)
coord. ref. : NA
values      : /home/data/amz.img
min value   : 0
max value   : 1

  This is what I would like to do:

>amz[-55,2]<-0.5

  Package "raster" offers a 'replacement' function that seemed promising, but its arguments are row and column numbers, instead of coordinates.

  Could anyone please point out another option?



More information about the R-sig-Geo mailing list