[R-sig-Geo] extracting values from rasters

Camilo Mora cmora at dal.ca
Mon Oct 8 05:55:08 CEST 2012


Thanks Robert,

I am exploring an option suggested by Barry and would like to explore  
yours to. A question I have though is how to use "extract" to a  
raster. According to the instructions extract takes the data from a  
raster on the areas overlapping polygons, lines, points and extents.  
But not info on other rasters. Is there a trick to extract to another  
raster?

Thanks,

Camilo


Camilo Mora, Ph.D.
Department of Geography, University of Hawaii
Currently available in Colombia
Phone:   Country code: 57
          Provider code: 313
          Phone 776 2282
          From the USA or Canada you have to dial 011 57 313 776 2282
http://www.soc.hawaii.edu/mora/



Quoting "Robert J. Hijmans" <r.hijmans at gmail.com>:

> 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
>>>
>>>
>>>
>> ______________________________**_________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/**listinfo/r-sig-geo<https://stat.ethz.ch/mailman/listinfo/r-sig-geo>
>>
>



More information about the R-sig-Geo mailing list