[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-sig-geo
Subject:    Re: [R-sig-Geo] extract function - return the ID of the polygon
From:       Brian Oney <zenlines () gmail ! com>
Date:       2011-01-24 18:38:30
Message-ID: AANLkTi=D5Hq5bKd-oEkgC7SpkRD5xmNd3Lt-WQ0xPg=d () mail ! gmail ! com
[Download RAW message or body]

Sorry,
Robert didn't mean to call you Roger and ditto for Roger. I am guessing you
have (R-powered ?) search engines to see if posts pertain to you. Sorry
again for the mix-up.

Brian

On Mon, Jan 24, 2011 at 7:26 PM, Brian Oney <zenlines@gmail.com> wrote:

> Hello Roger,
> Using the extract function with a stack is exactly what I am doing. It is a
> handly little tool. Essentially one of the few ways (that I know) to handle
> large files from which a (much smaller) specific subset is required, while
> remaining within the limits of R and a laptop.
>
> I would have used the poly$FID or 1:N(polygons) and did at first but found
> that the numbers of my polygons did not match up. Looking back now it was
> probably operator error. Sometimes a foolproof method is better when the
> computer is working better than the brain.
>
> thanks for the handy package.
>
> cheers,
> Brian
>
>
> On 1/22/2011 5:40 PM, Brian Oney wrote:
>
>> Hello list,
>> I would like to know how to also reurn the ID of the polygon when using
>> the 'extract' function to extract raster cell values.
>> Honestly, I am just extracting and using the cell numbers to extract
>> values for these polygons in other raster layers for the same extent,
>> because it is so much faster.
>> Right now the one idea I have for the raster package would be to rasterize
>> the polygons and then extract using the same polygons and then take the cell
>> numbers and their values so that I would have a cell with a value for the
>> polygon to which it corresponds.
>>
>> poly.rast <- rasterize(poly, rast, field=c(poly$FID))
>> ex <- extract(poly.rast, poly, cellnumbers=T)
>>
>> I don't know how this would work with much larger files. My current
>> operation corresponds to ~12000 cells and could be faster.
>> Could be the problem that it is saturday and my brain is refusing to
>> work...
>>
>> A function that might be handy (and fast) in the future might be of the
>> cellFrom* function family (with an argument to carry over a polygon field ID
>> etc.).
>> Thanks for the help!
>> Best,
>> Brian
>>
>>


-- 
Brian Oney
Global Change Ecology
brian.j.oney (at) gmail.com
+4917638498570

	[[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic