[R-sig-Geo] ECMWF grib and raster

Robert Hijmans r.hijmans at gmail.com
Wed Jan 26 19:06:25 CET 2011


> I'm trying to read grib files using Raster, form the ECMWF interim 
> dataset (example file linked below). I don't get errors but the 
> coordinate system of the read raster does not seem to match. 

Bart, 

I think this is due to an instance of the "grid vs. cell-center convention
mistake" in gdal, reported here: http://trac.osgeo.org/gdal/ticket/2637 ,
but apparently not yet fixed. At least not in my gdal: "GDAL 1.7.2, released
2010/04/23" 

I confirmed that gdal gets it wrong using the 'degrib' software to export to
csv, and shapefile points and polygons. 

Here is a work-around:

> r <- raster( "tmp.grib" )
> r <- shift(r, x=-0.5*xres(r), y =0.5*yres(r))
> summary(rasterToPoints(r))
       x                 y             V3       
 Min.   :-180.00   Min.   :-90   Min.   :209.3  
 1st Qu.: -90.38   1st Qu.:-45   1st Qu.:269.5  
 Median :  -0.75   Median :  0   Median :283.6  
 Mean   :  -0.75   Mean   :  0   Mean   :279.1  
 3rd Qu.:  88.88   3rd Qu.: 45   3rd Qu.:296.9  
 Max.   : 178.50   Max.   : 90   Max.   :314.7  
> 

-- 
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/ECMWF-grib-and-raster-tp5962291p5963619.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list