[R-sig-Geo] Open raster _ extract pixel value

Robert Hijmans r.hijmans at gmail.com
Mon Mar 14 00:52:49 CET 2011


> I tried your suggestion doing this: 
> library(raster) 
> myobject
> <-raster("C:\\Users\\komine\\Desktop\\MODIS\\MYD09GQ.A2010280.h16v07.005.2010282160347.sur_refl_b01_1.tif") 
> e <- extent(-90, -32, -60, 15) 
> r <-
> crop("C:\\Users\\komine\\Desktop\\MODIS\\MYD09GQ.A2010280.h16v07.005.2010282160347.sur_refl_b01_1.tif",e) 
> plot(myobject) 

Komine, you can do:

library(raster) 
myobject
<-raster("C:\\Users\\komine\\Desktop\\MODIS\\MYD09GQ.A2010280.h16v07.005.2010282160347.sur_refl_b01_1.tif") 
plot(myobject)
click(myobject)   # and click somewhere on the map to get the value at that
location 
myobject[1]  # value of first cell
myobject[10,10]  # value of cell at row 10, column 10
extract(myobject, cbind(0,0))  # value at coordinates (0,0) (perhaps not on
your map)
?extract # for more info. 

Robert



--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Open-raster-extract-pixel-value-tp6166730p6167448.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list