Good afternoon everyone,
I am trying to make maps with sea surface temperature and a layer of continents. I have tried several ways and I get it wrong. My database is a .nc file, where after loading the data I have an large array (sst) of 3 dimensions (lon=360, lat=180, time=360), since they are monthly averages in a series of 30 years (12*30=360).
On my first attempt I get a map that would seem to be ok, but it is 90° rotated. I understand that it must be some coordinate problem but I can't identify which one. This is my script and map:
sst1 <- sst[,,1] #i keep with only the time dimension
sst1 <- sst1*masc #multiply de values by the mask, in order to have the continents in the map
sst_media <- apply(sst1, c(1,2), mean) #calculate the mean for the hole period
mapa <- raster(sst1, xmn=0, xmx=360, ymn=-90, ymx=90)
plot(mapa, col=rev(brewer.pal(10,"RdBu")),
main="Temperatura media (°C) durante el período 1983-2012",
xlab="Longitud",
ylab= "Latitud",
cex.main=1,
cex.axis=0.5,
cex.lab=0.6)
On my second attempt, the map is horizontal, but the continents are inverted. My script and map:
rgb.palette <- colorRampPalette(c('darkblue','palegreen1','yellow','red2'),interpolate='spline')
filled.contour(lon, lat2, sst1, color.palette=rgb.palette,
plot.title=title(main="Temperatura media (°C) durante el periodo 1983-2012",
xlab="Longitud", ylab="Latitud"),
plot.axes={axis(1); axis(2);map("world2", add=TRUE);grid()})
Thank you for advance for your help!