PlotEquiMap: Poorly reorganized lon/lat if the input is not regularly spaced
PlotEquiMap() expected regularly-spaced longitude and latitude. In some cases, the lon/lat is not regularly spaced and the function re-organizes lon/lat wrongly. The data can still be plotted but some features (e.g., country.border = T
) is not functional.
The "regularly spaced" requirement is documented but there is no check in the function. And for many cases, the data can still be plotted, so we're not sure what's the exact criteria of "regular spaced".
For a specific case (script below), the country border is not plotted and the problematic part is line 721-725. Without the wrong sorting, the longitude can remain correct and borders can be plotted.
library(s2dv)
x <- readRDS('/home/Earth/aho/aho-testtest/s2dv/issue/issue60/data.rds')
s2dv::PlotEquiMap(var = x$data, lon = x$lon, lat = x$lat, coast_color = 'black',
colNA = 'grey', axelab = FALSE, brks = seq(0.5,12.5,1),
triangle_ends = c(F,F), bar_label_scale = 2,
toptitle = 'title', country.borders = TRUE, coast_width = 2,
filled.continents = FALSE, filled.oceans = 'grey',
height = 10, width = 18, res = 300, fileout = NULL)
FYI @cdelgado