netcdf - Plotting country borders with maptools - R -


following excelent post joe wheatley (http://joewheatley.net/ncep-global-forecast-system/) managed produce temperature global map. but, instead of plotting coastline i've tried use maptools package plot country borders. problem comes when eastern hemisphere country borders plotted. should missing can't figure out, still looking on stackoverflow , google. hope can help.

here code i'm using (most coming joe's post)

loc=file.path("ftp://ftp.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.2013052100/gfs.t00z.sfluxgrbf03.grib2") download.file(loc,"temp.grb",mode="wb")  system("wgrib2 -s temp.grb | grep :tmp: | wgrib2 -i temp.grb -netcdf tmp.nc",intern=t) system("wgrib2 -s temp.grb | grep :land: | wgrib2 -i temp.grb -netcdf temp.nc",intern=t)  library(ncdf) landfrac <-open.ncdf("land.nc") lon <- get.var.ncdf(landfrac,"longitude") lat <- get.var.ncdf(landfrac,"latitude")  temp=open.ncdf("tmp.nc") t2m.mean <- get.var.ncdf(temp,"tmp_2maboveground")   library("fields") library("sp", lib.loc="/usr/lib/r/site-library") library("maptools", lib.loc="/usr/lib/r/site-library")  day="dia"  png(filename="gfs.png",width=1215,height=607,bg="white")  rgb.palette <- colorramppalette(c("snow1","snow2","snow3","seagreen","orange","firebrick"), space = "rgb")#colors image.plot(lon,lat,t2m.mean,col=rgb.palette(200),main=as.expression(paste("gfs 24hr average 2m temperature",day,"00 utc",sep="")),axes=t,legend.lab="o c") data(wrld_simpl) plot(wrld_simpl, add = true)  dev.off() 

and image produced

enter image description here

this global map, should use xlim , ylim in image.plot extract region (i.e. europe)

edit: added url temp.nc file

http://ubuntuone.com/29dkaerjuciczlblgfslc9

any appreciated, thanks

the data set wrld_simpl aligned on longitudes [-180, 180] grid data [0,360]. since have maptools loaded try add modified copy plot:

plot(elide(wrld_simpl, shift = c(360, 0)), add = true) 

there other tools crop , move/combine , recentre data this, including ?rotate in package raster. depends on need.

another graphics-alternative use "world2" in maps package

library(maps) map("world2", add = true) 

either of work finish plot started above.

here's discussion related this: fixing maps library data pacific centred (0°-360° longitude) display


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -