Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

having 12 files with 12 hdrs for one year: these files are raster (projected WGS84,lat long):https://echange-fichiers.inra.fr/get?k=rLSyoavrnifGyH5XrlO

          samples = 1440
           lines   = 720
           bands   = 1
           header offset = 0
           file type = ENVI Standard
           data type = 4
           interleave = bsq
            byte order = 0
      map info = {  Geographic Lat/Lon, 1, 1, -180, 90, 0.25, 0.25,WGS-84}
        coordinate system string = GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",
                 SPHEROID["WGS_1984",6378137,298.257223563]]
       ,PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
                 }

These lines will open the files as a list:

      a<-list.files("D:\\ECV\\2010", "*.envi", full.names = TRUE)
           for(i in 1:length(a)){
            d <- raster(a[i]}

I would like to extract the values correspond to 44.8386° N, 0.5783° W from all files as txt file

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

Curlew's answer can be improved upon like this (do not use a loop, and use a RasterStack)

library(raster)
files <- list.files("D:\\ECV\\2010", "*.envi", full.names = TRUE)
s <- stack(files)
point <- cbind(44.8386, 0.5783)
result <- extract(s, point)
share|improve this answer
add comment

Assuming that you know how to create a point shape out of your longitude, latitude value:

library(raster);library(rgdal)
point_location <- readOGR("Foldername","filename")
a<-list.files("D:\\ECV\\2010", "*.envi", full.names = TRUE)
result <- data.frame(ID=seq(1,length(a)),Value=rep(NA,length(a))
for(i in 1:length(a)){
   d <- raster(a[i])
   result$Value[i] <- extract(d,point_location)     
}

EDIT: The quick and dirty way to do it manually in QGIS

  • Load in your NVDI raster layers and Create a new point layer with WGS84 (http://imgur.com/HR1oEaG)
  • Set the new point layer on EDIT-Mode and go to the address field on the bottom of your QGis window
  • Here add your longitude,latitude values (http://imgur.com/UpeunXm),press return and zoom to your address. This is very dirty and not exact. If you want exact values you should search how to convert those values to a shapefile in QGIS (i would try to use the add text-delimited file and create a .csv file with your locations first.)
  • Now add a point to your new layer on this location and save.
  • Open the Plugin Downloader and download the Point Sampling Tool. The Rest is self-explaining.
share|improve this answer
    
what you mean by "Assuming that know how to create a point shape out of your longitude, latitude value:" what folder name and file name refer to? in point_location –  Jonsson Jan 27 '13 at 13:12
    
well, you need to create a point shapefile with your longitude, latitude values. readOGR needs the directory and the filename (without extension). Like this readOGR("D:/Data/GIS","location") to load in location.shp –  Curlew Jan 27 '13 at 13:32
    
so first I create a point shape out of my longitude, latitude value(which I do not know how to do it)then i use the code above,third I use writetable to write the results.I wonder if you tried it,it worked? –  Jonsson Jan 27 '13 at 13:40
    
correct, i just tried it out and it works without any problems (i.imgur.com/kf7Ei3M.png). I made a test point somewhere near your location (using QGIS). Please test it yourself :-) –  Curlew Jan 27 '13 at 14:01
    
could you please tell me how did you do it(I can not create the shape file,please add the steps of creating the shapefile).Or please explain how we can do it using QGIS as a second answer?I have been struggling for long time –  Jonsson Jan 27 '13 at 14:07
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.