I have an .nc file that I'm trying to plot a map out of. I got my data here: https://www.esrl.noaa.gov/psd/data/gridded/data.UDel_AirT_Precip.html (precip.mon.ltm.v301.nc). The latitude starts from 89.75
to -89.75
. Longitude starts from 0.25
to 359.75
. This is what I did:
File1<-Sys.glob("precip.mon.ltm*.nc")
tmfile<-File1
pr_file<-nc_open(tmfile)
lat=ncvar_get(pr_file,'lat')
lon=ncvar_get(pr_file,'lon')
time=ncvar_get(pr_file,'time')
precip=ncvar_get(pr_file,'precip')
image.plot(lon,lat,precip[,,1],main="Precipitation")
Error in image.default(..., breaks = breaks, add = add, col = col) : increasing 'x' and 'y' values expected
lat1<-sort(lat)
image.plot(lon,lat1,precip[,,1],main="Precipitation",zlim=c(0,20))
Then the map comes out, but upside down. ie, Antartica is on top. How do I turn my map the right way round?