I have a NetCDF file of salinity in Indonesia water with 4 dimensions (lon, lat, depth and time), download data here: https://onedrive.live.com/redir?resid=6FFDD661570C7D0A%21177
I would like plot salinity data with the same range (minimum - maximum) values using levelplot
(rastesVis
package). Unfortunately, I get different range of value for each of my plot. The at=seq(20, 35, 2)
did not define the same range in my plot?
This is my script:
# Note: Work perfectly after update 'rasterVis package'
# import data
sal <- brick('data.nc', level=1, varname = "salinity")
sal[sal == -32767] <- NA
# colorramp
jet.colors <- colorRampPalette(c('#00007F', 'blue', '#007FFF',
'cyan','#7FFF7F', 'yellow', '#FF7F00',
'red', '#7F0000'))
# create levelplot
for (i in 1:5) { # 5 different time in the same depth/level
png = paste0('D:/sal_',i,'.png')
png(png, width=2200, height=2200, res=300)
print(levelplot(subset(sal,i),
col.regions = jet.colors(255),
at=seq(20, 34, 1),
yscale.components=yscale.raster.subticks,
xscale.components=xscale.raster.subticks,
margin=FALSE, ylab='latitude', xlab='longitude',
main='salinity (psu)'))
dev.off()
}