On Sun, Oct 7, 2012 at 10:58 AM, Camilo Mora <cmora at dal.ca> wrote:
Thanks Barry,
I did try resample. Unfortunately, it is taking about 15 minutes and after
that it says that it failed returning the message "Reached total allocation
of 5813Mb: see help(memory.size)".
I have made some changes in resample to hopefully avoid this in the future.
You can probably also avoid this lowering the default values for chunksize
and maxmemory (see ?setOptions)
I converted my habitat raster to points (about 500,000) and use the
"extract" fucntion. it does the extraction in about two minutes, which
makes me realize that the resample function is taking to long because of
the interpolation method.
You could use
extract( , method='bilinear')
assuming that you two rasters have more or less the same resolution (or at
least that the resolution of the raster where you extract values from is
not much higher than that of the other raster)
Do you know if there is an analogous function to resample that considers
just the overlap of cells to assing values?.
Thanks,
Camilo
http://www.soc.hawaii.edu/**mora/ <http://www.soc.hawaii.edu/mora/>
Quoting Barry Rowlingson <b.rowlingson at lancaster.ac.uk>**:
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