From a874cac86d8992ba9e5022090e55482ebc448bb7 Mon Sep 17 00:00:00 2001 From: aho Date: Mon, 8 Aug 2022 17:16:37 +0200 Subject: [PATCH] Fix the bug of coastline when lon is not continuous --- R/PlotEquiMap.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/R/PlotEquiMap.R b/R/PlotEquiMap.R index ee10ec3..6405333 100644 --- a/R/PlotEquiMap.R +++ b/R/PlotEquiMap.R @@ -748,9 +748,10 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, # ~~~~~~~~~~~~~~~~~ # latb <- sort(lat, index.return = TRUE) - dlon <- lon[2:dims[1]] - lon[1:(dims[1] - 1)] + dlon <- diff(lon) wher <- which(dlon > (mean(dlon) + 1)) if (length(wher) > 0) { + warning("Detect gap in 'lon' vector, which is considered as crossing the border.") lon[(wher + 1):dims[1]] <- lon[(wher + 1):dims[1]] - 360 } lonb <- sort(lon, index.return = TRUE) @@ -942,7 +943,7 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, # Plotting continents # ~~~~~~~~~~~~~~~~~~~~~ # - wrap_vec <- c(lon[1], lon[1] + 360) + wrap_vec <- c(lonb$x[1], lonb$x[1] + 360) old_lwd <- par('lwd') par(lwd = coast_width) # If [0, 360], use GEOmap; if [-180, 180], use maps::map -- GitLab