Hi, I begin to work with R software to treat raster data. Now, I have a NDVI image with a tiff extension. I want to open this image and to extract NDVI value for some pixel which I have their coordinates. 1- Please what is the code to open a tiff image with R ? 2- How to extract the value of some pixel which I have their coordinate ? NB: I hope you understand my questions with my bad English. Thank you -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Open-raster-extract-pixel-value-tp6166730p6166730.html Sent from the R-sig-geo mailing list archive at Nabble.com.
Open raster _ extract pixel value
10 messages · Roger Bivand, Komine, Roman Luštrik +2 more
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110313/857c7de9/attachment.pl>
On Sun, 13 Mar 2011, Roman Lu?trik wrote:
See package raster and its extensive documentation. Cheers, Roman
An oblique remark - a translation of the Spatial task view page into Belorussian by Amanda Lynn is at: http://webhostingrating.com/libs/analysis-of-spatial-data-be If other translations became available (volunteers welcome), perhaps the ctv Task View mechanism could be internationalised? Roger
On Sun, Mar 13, 2011 at 6:33 PM, Komine <momadou at yahoo.fr> wrote:
Hi, I begin to work with R software to treat raster data. Now, I have a NDVI image with a tiff extension. I want to open this image and to extract NDVI value for some pixel which I have their coordinates. 1- Please what is the code to open a tiff image with R ? 2- How to extract the value of some pixel which I have their coordinate ? NB: I hope you understand my questions with my bad English. Thank you -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Open-raster-extract-pixel-value-tp6166730p6166730.html Sent from the R-sig-geo mailing list archive at Nabble.com.
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no
Thank for your answers,
But I don't arrive to open my raster.After to download raster package, I
tried this code to open my raster but, there is an error:
My code=
r<-read.raster("C:\\Users\\Komine\\Desktop\\MODIS\\MYD09GQ.A2010280.h16v07.005.2010282160347.sur_refl_b01_1.tif",package="raster")
Please, where is the error?
Thanks again.
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Open-raster-extract-pixel-value-tp6166730p6167068.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110313/9571f6b2/attachment.pl>
Dear all,
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)
the result is here:
library(raster)
myobject <-
raster("C:\\Users\\komine\\Desktop\\MODIS\\MYD09GQ.A2010280.h16v07.005.2010282160347.sur_refl_b01_1.tif")
Fixing "AREA_OR_POINT=Point" georeference
e <- extent(-90, -32, -60, 15)
r <-
crop("C:\\Users\\komine\\Desktop\\MODIS\\MYD09GQ.A2010280.h16v07.005.2010282160347.sur_refl_b01_1.tif",e)
Erreur dans function (classes, fdef, mtable) : unable to find an inherited method for function "crop", for signature "character"
plot(myobject)
However the raster appear in spite of the previous error message. 1- I suppose that I did an error although R read my raster? 2- Could you explain me the meaning of: extent(-90, -32, -60, 15) Thanks for your help -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Open-raster-extract-pixel-value-tp6166730p6167299.html Sent from the R-sig-geo mailing list archive at Nabble.com.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20110313/d6d0ba52/attachment.pl>
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.
Thanks to all for your answers, I progress!
Robert, after to try your code, all is ok. Now I try to open a NDVI image
with HRD extension. Also almost all is ok with the next code:
library(raster)
myobject <-raster("C:\\Users\\komine\\Desktop\\MODIS2\\NDVI_280")
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(496439.36,1662612.38)) # value at coordinates
- However, the image NDVI don?t appear well because I have a color on the
raster map like a mask,
- Also, I compare to verify a pixel value NDVI extract from R and the ENVI
software (like Erdas) but I have two differences values for the same pixel
(for the past coordinates, pixel value from R= -0.5376111 whereas for ENVI=
-0.586962)
Could you help on this problem?
Thanks again
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Open-raster-extract-pixel-value-tp6166730p6171051.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
Dear, Thanks, pixel value is ok, in fact I must put 4 numbers after the gamma. But the image NDVI don't appear good with a color on all the map although the pixel values are correct. Thank you -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Open-raster-extract-pixel-value-tp6166730p6172015.html Sent from the R-sig-geo mailing list archive at Nabble.com.