Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After downloading the data file, I can read directly with raster. I choose band 221 that (if I am not wrong) it is what you need according to <a href="http://www.nco.ncep.noaa.gov/pmb/products/gfs/gfs.t00z.pgrb2f00.shtml" rel="noreferrer">this table</a>:</p> <pre><code>library("raster") t2mc &lt;- raster('gfs.grb', band=221) &gt; t2mc class : RasterLayer band : 221 (of 315 bands) dimensions : 361, 720, 259920 (nrow, ncol, ncell) resolution : 0.5, 0.5 (x, y) extent : -0.25, 359.75, -90.25, 90.25 (xmin, xmax, ymin, ymax) coord. ref. : +proj=longlat +a=6371229 +b=6371229 +no_defs data source : /home/oscar/gfs.grb names : gfs </code></pre> <p>You don't need the whole extent so you use <code>crop</code> to get the desired extent:</p> <pre><code>e &lt;- extent(-40,40,20,90) tt &lt;- crop(t2mc,e) </code></pre> <p>I have tried to display the <code>tt</code> raster with <code>plot</code> without success. However, it works correctly with <code>spplot</code> if you use a different extent (89.5 instead of 90):</p> <pre><code>e &lt;- extent(-40,40,20,89.5) tt &lt;- crop(t2mc,e) spplot(tt) </code></pre> <p>Now we have to add the administrative boundaries:</p> <pre><code>library(maps) library(mapdata) library(maptools) ext &lt;- as.vector(e) boundaries &lt;- map('worldHires', xlim=ext[1:2], ylim=ext[3:4], plot=FALSE) boundaries &lt;- map2SpatialLines(boundaries, proj4string=CRS(projection(tt))) </code></pre> <p>and change the palette:</p> <pre><code>rgb.palette &lt;- colorRampPalette(c("snow1","snow2","snow3","seagreen","orange","firebrick"), space = "rgb") spplot(tt, col.regions=rgb.palette, colorkey=list(height=0.3), sp.layout=list('sp.lines', boundaries, lwd=0.5)) </code></pre> <p><img src="https://i.stack.imgur.com/53ReY.png" alt="spplot result"></p> <p>If you prefer the <code>latticeExtra::layer</code> approach, you can achieve a similar result with this code:</p> <pre><code>library(rasterVis) levelplot(tt, col.regions=rgb.palette, colorkey=list(height=.3)) + layer(sp.lines(boundaries, lwd=0.5)) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload