Re: [D-RUG]: How to extract values from a raster?

7 views
Skip to first unread message
Message has been deleted

Erica Rettig

unread,
Apr 14, 2017, 12:56:04 PM4/14/17
to davi...@googlegroups.com
extract() will let you extract from an extent object:

> r <- raster(ncol=10, nrow=10)
> values(r) <- 1:ncell(r)
> r2 <- extent(-180,180,49,51)
> extract(r, r2)
 [1] 21 22 23 24 25 26 27 28 29 30

to only get 1 cell, set the ymin/max based on the cell size of r to be one cell tall.


On Fri, Apr 14, 2017 at 9:00 AM, bic ton <bict...@gmail.com> wrote:
Hi everyone,

I have a raster 
library (raster)
r <- raster(ncol=10, nrow=10)
values(r) <- 1:ncell(r)
plot(r)

Now in the plot you see, I need to extract all values for the latitude 50 (for all longitudes).
Any idea?
Thanks
Bic

--
Check out our R resources at http://d-rug.github.io/
---
You received this message because you are subscribed to the Google Groups "Davis R Users' Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to davis-rug+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/davis-rug.
For more options, visit https://groups.google.com/d/optout.



--
Thanks,
Erica


Erica Rettig
PhD Candidate
Graduate Group in Ecology, UC Davis
Reply all
Reply to author
Forward
0 new messages