PlotEquiMap(): Poor warning message and wrong output when longitude is not strictly ascending
The document of parameter lon
says:
#'@param lon Numeric vector of longitude locations of the cell centers of the
#' grid of 'var', in ascending or descending order (same as 'var'). Expected
#' to be regularly spaced, within either of the ranges [-180, 180] or
#' [0, 360]. Data for two adjacent regions split by the limits of the
#' longitude range can also be provided, e.g. \code{lon = c(0:50, 300:360)}
#' ('var' must be provided consitently).
According to this, the longitude vector c(340:359, 0:19)
is not allowed. However, it returns a plot still (wrong) with the warnings:
Warning messages:
1: ! Warning: Detect gap in 'lon' vector, which is considered as crossing the border.
2: In (wher + 1):dims[1] :
numerical expression has 38 elements: only the first used
3: In (wher + 1):dims[1] :
numerical expression has 38 elements: only the first used
The function should return an error for this case.
Another case is, if longitude is cross the border AND the order is descending (i.e., c(359:340, 19:0)
), the result is wrong. IMO the descending order shouldn't be allowed for longitude, but it works for the continuous case like c(64:25)
.
data <- array(1:40, dim = c(lon = 40, lat = 40))
PlotEquiMap(data, lon = c(340:359, 0:19), lat = 11:50, filled.continents = F) #wrong
PlotEquiMap(data, lon = c(0:19, 340:359), lat = 11:50, filled.continents = F) #correct
PlotEquiMap(data, lon = rev(c(0:19, 340:359)), lat = 11:50, filled.continents = F) #wrong
PlotEquiMap(data, lon = c(64:25), lat = 11:50, filled.continents = F) #correct
PlotEquiMap(data, lon = c(25:64), lat = 11:50, filled.continents = F) #correct