[R-sig-Geo] extracting values from rasters

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Sun Oct 7 09:58:51 CEST 2012


On Sun, Oct 7, 2012 at 7:56 AM, Camilo Mora <cmora at dal.ca> wrote:
> Hi:
> I wonder if anyone knows a function to extract values from one raster
> to another raster when the rasters differ in resolution and extent. In
> other words extracting values just in overlapping cells.
>
> This is my specific problem: I have two rasters (one is for
> temperature worldwide and the other is for the presence of reefs also
> worldwide (the presence of reefs have values of 1 and all other cells
> as NA)). (the rasters differ in resolution and extent). I just need to
> put the values of the raster of temperature to each cell in the raster
> of reefs. Will you know a function that may do this?

 You want to start off looking at the 'resample' function in the
raster package. Read the note at the start of that about other
possibilities. Since your cells don't line up, there's various ways of
deciding what the value for a target cell is, including just sampling
the centre points, or interpolating overlapping cells in various ways.

Barry



More information about the R-sig-Geo mailing list