Skip to content
Prev 369562 / 398503 Next

Reversing one dimension of an array, in a generalized case

Hello Roy,
Perhaps you are aware of but I want to mention anyway. Basic issue is that you always want latitudes are monotonously increasing. Let me tell what I do when I read a ncdf file:

1- Set latitudes always monotonously decreasing (from 90 to -90)
2- Set longitudes always mononously increasing but from -180 to 180.
3- Set levels always monotonously decreasing (this is not relevant)

Why? If you plan to plot variables in R, you will need coordinates in this order. For instance, if you set latitudes monotonously increasing, your map will be plotted upside down. To fix this, you will need reverse dimension again. And also if your longitudes ranges from 0 to 360, you will see the only the east side of the plot on a world map. West of Greencwich will be empty.  They were the problems that I faced last year when I tried to plot netcdf files using lattice and rasterVis packages.